Mixin
Mixin copied to clipboard
Unable to access inner class, @Shadow does not seem to support it
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:
- Add @Shadow static class ModelDefinition; to the mixin:
- Compiler message: "Inner classes are only allowed if they are also @Mixin classes"
- 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.
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.