VazkiiMods / Zeta

Modular Mod development framework
Other
21 stars 5 forks source link

@ZetaLoadModule(clientReplacement = true) is pretty broken #5

Closed Jorue23 closed 2 months ago

Jorue23 commented 5 months ago

Now I tried to disable "Expanded Item Interactions" for Quark. This caused some weird issues with ghost items as already reported here: https://github.com/VazkiiMods/Quark/issues/4711 .

Now I played around a bit with the source code of Quark. While doing so I removed the code of this booleean https://github.com/VazkiiMods/Quark/blob/e3a3bf167935c6d5e1e3c0514853ba71e3dedaf2/src/main/java/org/violetmoon/quark/content/management/module/ExpandedItemInteractionsModule.java#L190 and only left the return false. I expected this to produce the result that gatherTooltip https://github.com/VazkiiMods/Quark/blob/d4a601088f676f4e598648b047bf56541d3548ea/src/main/java/org/violetmoon/quark/content/management/module/ExpandedItemInteractionsModule.java#L378 wouldn't render the tooltip anymore because it relies on armorOverride being true. Now this confused me because it changed nothing even tho it should've. So I just tried around and also removed gatherTooltip leaving an empty function. Now since gatherTooltip is inside a class annotated with "@ZetaLoadModule(clientReplacement = true)" this lead me to the presumption that the client replacement doesn't work at all. I'm not advanced enough in minecraft modding to figure out more information but maybe you can figure out why this behaviour is happening.

quat1024 commented 2 months ago

Hmm...

So clientReplacement is designed for modules that need to be different on the server and the client. On the dedicated server the outer module is loaded, and on the client the clientReplacement module is loaded instead.

Basically at some point the server calls new ExpandedItemInteractionsModule() and the client calls new ExpandedItemInteractionsModule.Client(). Because ZRenderTooltip is a client-only event, it can't go into ExpandedItemInteractionsModule because classloading that event on the server will crash.

That is the only thing clientReplacement does, so if you are seeing any tooltips from ExpandedItemInteractionsModule that means the clientReplacement functionality is working. I'm thinking maybe there is some other problem with the logic of the Quark module.

Jorue23 commented 2 months ago

Ok yeah makes sense then I understood the clientReplacement wrong. Sorry!