tinycodinglm / mc /mc-0016.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
3.14 kB
opencode trace
System You are an expert SpongePowered Mixin internals developer. You understand how mixins work at the bytecode level using ASM, and can debug, write, and optimize mixins.

You are an expert SpongePowered Mixin internals developer. You understand how mixins work at the bytecode level using ASM, and can debug, write, and optimize mixins.

User

How do you diagnose mixin injection failures? What are the most common error messages and their solutions?

Assistant

Mixin failures produce specific error messages that indicate the root cause. Here are the most common:

1. "Mixin failed to match target method"

java
// Error: @Inject(method = "tick") - target not found
// Cause: Method name or descriptor mismatch

// Fix: Verify method signature
@Mixin(LivingEntity.class)
public class MyMixin {
    // WRONG: descriptor doesn't match
    @Inject(method = "tick", at = @At("HEAD"))
    private void onTick(String arg) { } // tick()V takes no args!
    
    // CORRECT:
    @Inject(method = "tick", at = @At("HEAD"))
    private void onTick(CallbackInfo ci) { }
}

2. "No injection point found"

java
// Error: Could not find injection point in target
// Cause: @At target doesn't exist in the method

// Fix: Use the correct injection point
@Inject(
    method = "damage",
    at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/entity/LivingEntity;applyArmorToDamage(...)F" // wrong method
    )
)

// Use correct target (check Yarn mappings):
@At(
    value = "INVOKE",
    target = "Lnet/minecraft/entity/damage/DamageSource;getAmount()F"
)

3. "Injection point is ambiguous"

java
// Error: Multiple injection points match
// Cause: ordinal not specified for duplicate calls

// Fix: Specify ordinal or use slice
@Inject(
    method = "tick",
    at = @At(value = "INVOKE", target = "...", ordinal = 1) // second occurrence
)

4. "Mixin could not be applied"

java
// Error: mixin could not be applied to target class
// Cause: Target class doesn't exist or wasn't loaded

// Fix: Ensure target exists in the runtime environment
@Mixin(value = TargetClass.class, remap = false) // disable remapping if needed

5. "Conflicting redirection"

java
// Error: Two mixins redirect the same call
// Cause: Multiple @Redirect on same target

// Fix: Use @WrapOperation instead, or coordinate with other mods
@WrapOperation(
    method = "tick",
    at = @At(value = "INVOKE", target = "...")
)
private float wrapHealth(Operation<Float> original) {
    return original.call() * 2.0f;
}

Debugging checklist:

  1. Check refmap generation - is it mapping correctly?
  2. Verify Yarn mappings version matches Minecraft version
  3. Use @Mixin(remap = false) for non-mapped targets
  4. Add -Dmixin.debug=true JVM flag for verbose output
  5. Check the mixin debug log at latest.log for injection details