Skip to content

How to see what your mixin did to the game's code (Minecraft mod)

Add @Debug(export = true, print = true) to a mixin class. When the game starts, Mixin writes the finished target class to .mixin.out/class in the run folder, and prints it to the log, so you can read the code your @Inject became. If the mixin does not apply, the log names the cause: a wrong method name or descriptor (Target method not found), a class missing from the mixins json, or an obfuscated name in a dev run. Remove @Debug before you publish.

Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.16.5 to 26.3 on Fabric; Minecraft 1.16.5 to 1.20.1 on Forge; Minecraft 1.12.2 on Forge. Each example was compiled against its loader and version before it shipped in Linen.

  1. Add @Debug(export = true, print = true) above your @Mixin class.
  2. Run the game once and open run/.mixin.out/class.
  3. Find your injected code in the exported class.
  4. Fix the method name or at point if the log says it was not found, then remove @Debug.

The example mod is examplemod in the package com.example.examplemod. Use your own mod id and package.

Fabric and NeoForge 1.20.4 to 1.21.1, NeoForge 1.20.1 to 1.20.2, Fabric 1.16.5 to 1.20.3, Fabric and NeoForge 1.21.2 to 26.3, Forge 1.17.1 to 1.20.1

Section titled “Fabric and NeoForge 1.20.4 to 1.21.1, NeoForge 1.20.1 to 1.20.2, Fabric 1.16.5 to 1.20.3, Fabric and NeoForge 1.21.2 to 26.3, Forge 1.17.1 to 1.20.1”

Uses:

  • @Debug
  • @Mixin
  • @Inject
  • LivingEntity.jumpFromGround

src/main/java/com/example/examplemod/mixin/DebugPeekMixin.java

package com.example.examplemod.mixin;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
// Debug Peek: @Debug writes LivingEntity as it looks after mixing to run/.mixin.out/class. Remove it before you publish.
@Debug(export = true, print = true)
@Mixin(LivingEntity.class)
public abstract class DebugPeekMixin {
@Inject(method = "jumpFromGround", at = @At("HEAD"))
private void examplemod$peek(CallbackInfo info) {
}
}

In src/main/resources/examplemod.mixins.json, add this to the list at /mixins:

"DebugPeekMixin"

Uses:

  • @Debug
  • @Mixin
  • @Inject
  • LivingEntity.jumpFromGround

src/main/java/com/example/examplemod/mixin/DebugPeekMixin.java

package com.example.examplemod.mixin;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
// Debug Peek: @Debug writes LivingEntity as it looks after mixing to run/.mixin.out/class. Remove it before you publish.
@Debug(export = true, print = true)
@Mixin(LivingEntity.class)
public abstract class DebugPeekMixin {
@Inject(method = "jumpFromGround", at = @At("HEAD"))
private void examplemod$peek(CallbackInfo info) {
}
}

In src/main/resources/examplemod.mixins.json, add this to the list at /mixins:

"DebugPeekMixin"

Uses:

  • @Debug
  • @Mixin
  • @Inject
  • EntityLivingBase.jumpFromGround

In 1.12.2 the method the example hooks is EntityLivingBase#jump.

src/main/java/com/example/examplemod/mixin/DebugPeekMixin.java

package com.example.examplemod.mixin;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
// Debug Peek: @Debug writes EntityLivingBase as it looks after mixing to run/.mixin.out/class. Remove it before you publish.
@Debug(export = true, print = true)
@Mixin(EntityLivingBase.class)
public abstract class DebugPeekMixin {
@Inject(method = "jump", at = @At("HEAD"))
private void examplemod$peek(CallbackInfo info) {
}
}

In src/main/resources/examplemod.mixins.json, add this to the list at /mixins:

"DebugPeekMixin"

Linen’s How-tos library has this page too, with the example for your own mod’s loader and Minecraft version. Hover a name in your code and Linen points to the how-tos that explain it. Both are free. Download Linen.