-
Notifications
You must be signed in to change notification settings - Fork 212
[Mixin] Warning against package-private submixin injector handlers. #2605
Description
Minecraft Development for IntelliJ plugin version
2026.1-1.8.12
Description of the feature request
Reason for Request
In environments other than Fabric's intermediary, it's possible to inadvertently mess up a submixin injector by making them package-private instead of protected. This is because while the mixin classes may be in the same package, the target classes may be in different packages at runtime.
This is not an issue on, for example, Fabric intermediary when targeting MC, because intermediary just has net.minecraft.class_xxxx for most class paths, but can be confusing in other situations.
A specific example is for example in 26.1, when using a submixin pattern on LivingEntity's hurtServer method as the parent, and Pig as the child. In 1.21.11 on Fabric, this works fine at runtime in prod even with package-private handlers, since intermediary doesn't have them in separate packages at runtime. But this would break in 26.1 and beyond.
Feature Description
For this specific case, the solution would be to make so that if in a @Mixin annotated class, a method overrides a parent @Mixin class's method, if the methods aren't protected, raising a warning.
A quick-fix option could also be added to refactor them to be protected automatically when selecting the member raising the warning.
Possible Expansions
More broadly, it's also arguable that mixin classes have no reason for package-private members in general, and that MCDev should warn against those even outside of submixin patterns.
This however might change with future Mixin versions, and the suggested quick-fix might need to be different based on what package-private member MCDev is warning about, which could make implementation more difficult.
I may try to make a PR for this myself if I find the will and time, but anyone is of course welcome to implement this if they so choose.