Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"@Inject not supported in interface mixin" when multiple mixins target the same method with different descriptors #75

Open
Fourmisain opened this issue Dec 5, 2021 · 0 comments

Comments

@Fourmisain
Copy link

Found this really weird issue that was hard to nail down, I guess it's best to just start with a minimal example.
Consider these 2 mixins:

@Mixin(Recipe.class)
public interface RecipeMixin1<C extends Inventory> {
	@Inject(method = "getRemainder", at = @At("RETURN"))
	default void testInject1(C container, CallbackInfoReturnable<DefaultedList<ItemStack>> cir) {

	}
}
@Mixin(Recipe.class)
public interface RecipeMixin2<C extends Inventory> {
	@Inject(method = "getRemainder(Lnet/minecraft/inventory/Inventory;)Lnet/minecraft/util/collection/DefaultedList;", at = @At("RETURN"))
	default void testInject2(C inventory, CallbackInfoReturnable<DefaultedList<ItemStack>> cir) {

	}
}

They are functionally identical and each of them works by themselves, but together they produce this error:

Mixin apply for mod amixintest1 failed amixintest1.mixins.json:RecipeMixin1 -> net.minecraft.class_1860:
org.spongepowered.asm.mixin.transformer.throwables.InvalidInterfaceMixinException amixintest1.mixins.json:RecipeMixin1->@Inject::testInject2(Lnet/minecraft/class_1263;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfoReturnable;)V from mod amixintest1 is not supported in interface mixin [ -> PREINJECT Applicator Phase -> amixintest1.mixins.json:RecipeMixin1 -> Prepare Injections]

Now for the really weird part, if both mixins have the exact same target descriptor, then they work perfectly fine in tandem!
If both injectors are in the same mixin class, they also work fine together.
When one or both of them target the intermediary name "method_8111", this issue disappears as well.

This issue also applies when two mods use different mappings, which is how I originally ran into it.
My Retro-Exchange PR modmuss50/Retro-Exchange#22 and a test mod of mine both have a Recipe mixin like above, only difference being that Retro-Exchange uses Mojmaps while the test mod uses yarn.

The InvalidInterfaceMixinException is thrown here

} catch (InvalidInjectionException ex) {
String description = ex.getContext() != null ? ex.getContext().toString() : "Injection";
throw new InvalidInterfaceMixinException(mixin, description + " is not supported in interface mixin");
}

no idea where the original InvalidInjectionException comes from, looking at #51 reveals nothing obvious either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant