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

Unable to access inner class, @Shadow does not seem to support it #578

Open
brunogenovese opened this issue May 15, 2022 · 1 comment
Open

Comments

@brunogenovese
Copy link

This might simply be a matter of not finding the right documentation, if so I would greatly appreciate if you can point me to it.

Problem:

  • Simply attempting to access an inner class while in a mixin, for example
  • ModelLoader.ModelDefinition x = new ModelLoader.ModelDefinition(myUnbakedModelList, myValues);
    
  • The compiler message is: "net.minecraft.client.render.model.ModelLoader.ModelDefinition' has private access in 'net.minecraft.client.render.model.ModelLoader"

Attempted solutions and their problems:

  1. Add @shadow static class ModelDefinition; to the mixin:
  • Compiler message: "Inner classes are only allowed if they are also @mixin classes"
  1. Create a Mixin for the inner class:
    @Mixin(ModelLoader.ModelDefinition.class) public class ModelLoaderMixinModelDefinition { }
    -Get the same "private access" error on ModelDefinition. The error message in (1) seems to indicate that "there is a way" to make a mixin for an inner class but it is not clear what that is.

Conclusion:
A) If there is already mixin support for accessing inner classes, some documentation is necessary.
B) If there is no mixing support for accessing inner classes, it might be a good idea to add the functionality.

@embeddedt
Copy link

You can mixin to classes you're not allowed to access by passing the string name of the class:

@Mixin(targets = { "net.minecraft.client.render.model.ModelLoader$ModelDefinition" })
public class ModelDefinitionMixin {
}

However, depending on how much you need to access, there's a good chance you will still want to use an access transformer/widener to make the inner class public first. For example, you still can't declare any variables with that class as a type since you aren't supposed to have access to it.

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

2 participants