Skip to content

Mixins

Mixins are a core technology used by the Quilt ecosystem to modify Minecraft’s compiled bytecode as the game starts. They allow mods to inject custom code, modify existing behavior, access private members, or replace parts of the game’s implementation without directly editing Minecraft itself.

Since Minecraft is compiled and its classes cannot be modified directly, Quilt mods use the SpongePowered Mixin framework to patch the game’s bytecode at runtime. Mixins rely on Java annotations to specify exactly where and how code should be injected.

Common Types of Mixins:

@Inject

Injects custom code at the beginning, end, or another specified location within an existing method.

@ModifyVariable / @ModifyArg

Intercepts and modifies local variables or method arguments before they are used by Minecraft.

@Redirect

Redirects a specific method call or field access to your own implementation.

@Accessor / @Invoker

Provides access to private or protected fields and methods without modifying their visibility.

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin {
@Inject(method = "jump", at = @At("HEAD"))
private void onJump(CallbackInfo ci) {
// Runs whenever the player jumps.
}
}