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

Cannot Inject into Lambda's #571

Closed
hYdos opened this issue Apr 7, 2022 · 9 comments
Closed

Cannot Inject into Lambda's #571

hYdos opened this issue Apr 7, 2022 · 9 comments

Comments

@hYdos
Copy link

hYdos commented Apr 7, 2022

Mixin expects only public methods but it also wants all static methods to be private in a Mixin. Below is an example of how you can run into this issue.
Example Mixin:

@Mixin(RegistryAccess.class)
public interface RegistryAccessMixin {

    @Inject(method = "method_30531", at = @At("RETURN"), cancellable = true, locals = LocalCapture.PRINT)
    private static void hookBuiltinRegistriesEvent(@NotNull CallbackInfoReturnable<Map<ResourceKey<? extends Registry<?>>, RegistryAccess.RegistryData<?>>> cir) {
        //cir.setReturnValue(net.minecraftforge.experimental.registries.DataPackRegistriesHooks.addBuiltinRegistriesEvent(cir.getReturnValue()));
    }
}

This Mixin tries to inject into a lambda inside of the interface RegistryAccess. The bytecode of the class states that the method is public static synthetic method_30531()Lcom/google/common/collect/ImmutableMap; meaning that it requires the @Inject method to be static and private. The issue with this is that mixin will give Interface mixin contains a non-public method!. Setting the method to public will then make Mixin say Mixin dynamicRegistries.mixins.json:RegistryAccessMixin contains non-private static method

@hYdos hYdos changed the title Cannot Inject into Lambda's in 1.18.2 Cannot Inject into Lambda's Apr 7, 2022
@LlamaLad7
Copy link
Contributor

You can't inject in interfaces on stock mixin. This should probably be an issue on Fabric's fork.

@hYdos
Copy link
Author

hYdos commented Apr 7, 2022

This issue was ran into on a forge environment but thanks, Ill move the issue there.

@hYdos hYdos closed this as completed Apr 7, 2022
@hYdos
Copy link
Author

hYdos commented Apr 7, 2022

Forge doesnt seem to have a mixin fork. Are you sure vanilla mixin cant inject interfaces?

You can't inject in interfaces on stock mixin. This should probably be an issue on Fabric's fork.

@hYdos hYdos reopened this Apr 7, 2022
@LlamaLad7
Copy link
Contributor

LlamaLad7 commented Apr 7, 2022

Are you in an architectury environment? You seem to be using yarn

@hYdos
Copy link
Author

hYdos commented Apr 7, 2022

Are you in an architectury environment? You seem to be using yarn

Yep

@Earthcomputer
Copy link

Are you sure vanilla mixin cant inject interfaces?

Yes

@LlamaLad7
Copy link
Contributor

IIRC Architectury uses Fabric Mixin in dev even on Forge. Should be clear from the console output.

@hYdos
Copy link
Author

hYdos commented Apr 7, 2022

IIRC Architectury uses Fabric Mixin in dev even on Forge. Should be clear from the console output.

Oh alright my bad.

@hYdos hYdos closed this as completed Apr 7, 2022
@hYdos
Copy link
Author

hYdos commented Apr 8, 2022

This is actually an issue with Sponge Mixin. See #497

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

3 participants