ejektaflex / Bountiful

A Minecraft mod adding bounties for specific items.
https://minecraft.curseforge.com/projects/bountiful
GNU General Public License v3.0
82 stars 31 forks source link

[Bug]: Apparent crash when loaded alongside certain mods #258

Closed Bawnorton closed 6 months ago

Bawnorton commented 8 months ago

What happened?

You reference client-only classes in BountyItem, which causes the mod to crash when used on a dedicated server

https://github.com/ejektaflex/Bountiful/blob/dev/common/src/main/java/io/ejekta/bountiful/content/BountyItem.kt#L7

There are also references to client only code in common source here and here which will likely cause issues in future.

How can we reproduce it?

See https://github.com/Bawnorton/Neruina/issues/26#issue-1977031286

Mod Version

Latest

Mod Loader

Forge

Mod Loader Version

N/A

Relevant log output

Relevant Log ``` Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER at net.minecraftforge.fml.loading.RuntimeDistCleaner.processClassWithFlags(RuntimeDistCleaner.java:57) ~[fmlloader-1.20.1-47.2.0.jar%2369!/:1.0] at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) ~[modlauncher-10.0.9.jar%2355!/:?] at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113) ~[securejarhandler-2.1.10.jar:?] at cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) ~[securejarhandler-2.1.10.jar:?] at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) ~[securejarhandler-2.1.10.jar:?] at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) ~[securejarhandler-2.1.10.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] at io.ejekta.bountiful.content.BountyItem.m_7626_(BountyItem.java:35) ~[Bountiful-6.0.3+1.20.1-forge.jar%23221!/:?] at net.minecraft.world.item.ItemStack.m_41786_(ItemStack.java:580) ~[server-1.20.1-20230612.114412-srg.jar%23319!/:?] at net.minecraft.world.item.ItemStack.m_41611_(ItemStack.java:911) ~[server-1.20.1-20230612.114412-srg.jar%23319!/:?] at net.mcreator.createsweetsandtreets.procedures.SugarCookiePropertyValueProviderProcedure.execute(SugarCookiePropertyValueProviderProcedure.java:30) ~[Create%20Sweets%20And%20Treats%201.1.jar%23235!/:?] at net.mcreator.createsweetsandtreets.procedures.SugarCookiePropertyValueProviderProcedure.onPlayerTick(SugarCookiePropertyValueProviderProcedure.java:19) ~[Create%20Sweets%20And%20Treats%201.1.jar%23235!/:?] at net.mcreator.createsweetsandtreets.procedures.__SugarCookiePropertyValueProviderProcedure_onPlayerTick_PlayerTickEvent.invoke(.dynamic) ~[Create%20Sweets%20And%20Treats%201.1.jar%23235!/:?] at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] at net.minecraftforge.event.ForgeEventFactory.onPlayerPostTick(ForgeEventFactory.java:920) ~[forge-1.20.1-47.2.0-universal.jar%23324!/:?] at net.minecraft.world.entity.player.Player.m_8119_(Player.java:285) ~[server-1.20.1-20230612.114412-srg.jar%23319!/:?] at net.minecraft.server.level.ServerPlayer.m_9240_(ServerPlayer.java:467) ~[server-1.20.1-20230612.114412-srg.jar%23319!/:?] ... 12 more ```
ejektaflex commented 8 months ago

This is gross, but valid. It's only a client-side reference which isn't in the calling code at all, so it shouldn't call a runtime error. I've never had any problems testing it on a real server (and nobody else has ever said anything), so I wonder what would suddenly be calling it. Perhaps the RuntimeDistCleaner does not always run? Forge is pretty vague about these things.

This shouldn't ever happen with Fabric, since it does no runtime dist cleaning. Heck, it shouldn't cause an error in Forge either except that FML is detecting a reference during runtime, even though it's never called. Bleh.

Bawnorton commented 8 months ago

fair enough, $10 says it has something to do with

net.mcreator.createsweetsandtreets.procedures.SugarCookiePropertyValueProviderProcedure.execute(SugarCookiePropertyValueProviderProcedure.java:30)

then, could be an mc-creator moment

ejektaflex commented 8 months ago

That seemed to be the issue in #257 , so I'm going to blame MCreator as well. I'll keep this open as a low-priority thing to fix, though Bountiful isn't necessarily the culprit.

Thanks for the report!

ejektaflex commented 6 months ago

I'm not removing the Kambrik Prelaunch anytime soon, so I'm closing this as a dupe of #257