{"type": "session", "harness": "opencode", "id": "mc-0016", "name": "Diagnosing mixin injection failures and common error messages"} {"type": "message", "message": {"role": "system", "content": "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."}} {"type": "message", "message": {"role": "user", "content": "How do you diagnose mixin injection failures? What are the most common error messages and their solutions?"}} {"type": "message", "message": {"role": "assistant", "content": "Mixin failures produce specific error messages that indicate the root cause. Here are the most common:\n\n**1. \"Mixin failed to match target method\"**\n\n```java\n// Error: @Inject(method = \"tick\") - target not found\n// Cause: Method name or descriptor mismatch\n\n// Fix: Verify method signature\n@Mixin(LivingEntity.class)\npublic class MyMixin {\n // WRONG: descriptor doesn't match\n @Inject(method = \"tick\", at = @At(\"HEAD\"))\n private void onTick(String arg) { } // tick()V takes no args!\n \n // CORRECT:\n @Inject(method = \"tick\", at = @At(\"HEAD\"))\n private void onTick(CallbackInfo ci) { }\n}\n```\n\n**2. \"No injection point found\"**\n\n```java\n// Error: Could not find injection point in target\n// Cause: @At target doesn't exist in the method\n\n// Fix: Use the correct injection point\n@Inject(\n method = \"damage\",\n at = @At(\n value = \"INVOKE\",\n target = \"Lnet/minecraft/entity/LivingEntity;applyArmorToDamage(...)F\" // wrong method\n )\n)\n\n// Use correct target (check Yarn mappings):\n@At(\n value = \"INVOKE\",\n target = \"Lnet/minecraft/entity/damage/DamageSource;getAmount()F\"\n)\n```\n\n**3. \"Injection point is ambiguous\"**\n\n```java\n// Error: Multiple injection points match\n// Cause: ordinal not specified for duplicate calls\n\n// Fix: Specify ordinal or use slice\n@Inject(\n method = \"tick\",\n at = @At(value = \"INVOKE\", target = \"...\", ordinal = 1) // second occurrence\n)\n```\n\n**4. \"Mixin could not be applied\"**\n\n```java\n// Error: mixin could not be applied to target class\n// Cause: Target class doesn't exist or wasn't loaded\n\n// Fix: Ensure target exists in the runtime environment\n@Mixin(value = TargetClass.class, remap = false) // disable remapping if needed\n```\n\n**5. \"Conflicting redirection\"**\n\n```java\n// Error: Two mixins redirect the same call\n// Cause: Multiple @Redirect on same target\n\n// Fix: Use @WrapOperation instead, or coordinate with other mods\n@WrapOperation(\n method = \"tick\",\n at = @At(value = \"INVOKE\", target = \"...\")\n)\nprivate float wrapHealth(Operation original) {\n return original.call() * 2.0f;\n}\n```\n\n**Debugging checklist:**\n\n1. Check `refmap` generation - is it mapping correctly?\n2. Verify Yarn mappings version matches Minecraft version\n3. Use `@Mixin(remap = false)` for non-mapped targets\n4. Add `-Dmixin.debug=true` JVM flag for verbose output\n5. Check the mixin debug log at `latest.log` for injection details"}}