CursedFlames / MCTweaks

A monorepo containing a collection of tweak mods for Minecraft.
Other
2 stars 0 forks source link

[Split Shulkers] Consider using Mixin inheritance for improved mod compatibility #3

Open RubixDev opened 7 months ago

RubixDev commented 7 months ago

Hi, I'm the author of EnchantedShulkers, and I got a request to make my mod compatible with yours https://github.com/RubixDev/EnchantedShulkers/issues/21. While working on that, I learned about Mixin Inheritance, which is preferred over just overriding entire vanilla methods in mixins. I am mainly talking about the getUpdatePacket() and getUpdateTag() methods in the MixinShulkerBoxBlockEntity class:

https://github.com/CursedFlames/MCTweaks/blob/1feecdf18203ea223b8641b948630ee5c7898e36/SplitShulkerBoxes/common/src/main/java/cursedflames/splitshulkers/mixin/MixinShulkerBoxBlockEntity.java#L70-L85

You can see how I "override" the same two methods on my side here and here (note: I'm using yarn mappings so the names are different).

While a change on your side technically isn't necessary, it would still be good practice to do so and a step forward for better compatibility between your mod and other mods like Shulker+.


Additionally you should consider relying less on ci.cancel() calls. Mainly https://github.com/CursedFlames/MCTweaks/blob/1feecdf18203ea223b8641b948630ee5c7898e36/SplitShulkerBoxes/common/src/main/java/cursedflames/splitshulkers/mixin/client/MixinBlockEntityWithoutLevelRenderer.java#L50-L58 and https://github.com/CursedFlames/MCTweaks/blob/1feecdf18203ea223b8641b948630ee5c7898e36/SplitShulkerBoxes/fabric/src/main/java/cursedflames/splitshulkers/mixin/client/MixinShulkerBoxRenderer.java#L28-L47 caused some trouble. For ensuring compatibility between our mods I had to mixin into your mixins in these places to basically just apply the same modifications that I do to the vanilla game.

CursedFlames commented 3 weeks ago

I've rewritten the mixins to hopefully be less invasive in 1b7ee9a; let me know if there's anything else that could be changed to improve compat.