Curios API (Fabric)

Curios API (Fabric)

819k Downloads

[Bug]: NeoForge PayloadRegistrar's client() method does not prevent loading of client classes on server side

TigerWalts opened this issue ยท 2 comments

commented

Minecraft Version

1.20.4

What happened?

Server crashes on start up during the registration of custom packet payload handlers.

Referencing the NeoForge docs:

https://docs.neoforged.net/docs/networking/payload

@SubscribeEvent
public static void register(final RegisterPayloadHandlerEvent event) {
    final IPayloadRegistrar registrar = event.registrar("mymod");
    registrar.play(MyData.ID, MyData::new, handler -> handler
            .client(ClientPayloadHandler.getInstance()::handleData)
            .server(ServerPayloadHandler.getInstance()::handleData));
}

If the handleData method uses client-only class instances then the server will crash with a ClassNotFoundException.

Curiously, wrapping the method inside a lambda will avoid the error:

How do you trigger this bug?

  1. Run on a dedicated server

Loader

NeoForge

Loader Version

NeoForge 20.4.225

Mod Version

Curios API 7.3.4+1.20.4

Relevant Log Outputs

https://mclo.gs/NLRuapK

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.player.LocalPlayer
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMemberReference(MixinPreProcessorStandard.java:786) ~[sponge-mixin-0.13.1+mixin.0.8.5.jar%2379!/:0.13.1+mixin.0.8.5]
	...
	at org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131) ~[sponge-mixin-0.13.1+mixin.0.8.5.jar%2379!/:0.13.1+mixin.0.8.5]
	at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156) ~[modlauncher-10.0.9.jar%2365!/:10.0.9+10.0.9+main.dcd20f30]
	at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) ~[modlauncher-10.0.9.jar%2365!/:?]
	at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-10.0.9.jar%2365!/:?]
	at cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) ~[modlauncher-10.0.9.jar%2365!/:?]
	at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:169) ~[securejarhandler-2.1.24.jar:?]
	at cpw.mods.cl.ModuleClassLoader.lambda$findClass$20(ModuleClassLoader.java:275) ~[securejarhandler-2.1.24.jar:?]
	at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:288) ~[securejarhandler-2.1.24.jar:?]
	at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:275) ~[securejarhandler-2.1.24.jar:?]
	at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:191) ~[securejarhandler-2.1.24.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
	at top.theillusivec4.curios.common.network.NetworkHandler.lambda$register$5(NetworkHandler.java:57) ~[curios-neoforge-7.3.4+1.20.4.jar%23394!/:7.3.4+1.20.4]
	at net.neoforged.neoforge.network.registration.ModdedPacketRegistrar.play(ModdedPacketRegistrar.java:74) ~[neoforge-20.4.225-universal.jar%23573!/:?]
	at top.theillusivec4.curios.common.network.NetworkHandler.register(NetworkHandler.java:56) ~[curios-neoforge-7.3.4+1.20.4.jar%23394!/:7.3.4+1.20.4]
	at top.theillusivec4.curios.Curios.registerPayloadHandler(Curios.java:106) ~[curios-neoforge-7.3.4+1.20.4.jar%23394!/:7.3.4+1.20.4]
	at net.neoforged.bus.ConsumerEventHandler.invoke(ConsumerEventHandler.java:26) ~[bus-7.2.0.jar%2370!/:?]
	at net.neoforged.bus.EventBus.post(EventBus.java:386) ~[bus-7.2.0.jar%2370!/:?]
	at net.neoforged.bus.EventBus.post(EventBus.java:365) ~[bus-7.2.0.jar%2370!/:?]
	at net.neoforged.fml.ModContainer.acceptEvent(ModContainer.java:210) ~[loader-2.0.17.jar%2362!/:2.0]
	... 31 more
commented

I can't reproduce this, a dedicated server doesn't crash on my end. I see something called inventorio-neoforge.mixins.json injects into the Curios networking class. Can you try testing without Inventorio?

commented

That does seem to be the culprit.

Already reported and fixed https://www.github.com/RubixDev/Inventorio/issues/339