Create Deco

Create Deco

11M Downloads

Sneak clicking a railing with a create wrench crashes server

spectrapulse opened this issue ยท 6 comments

commented

MC Version: 1.20.1
Create version: v0.5.1-d-build.1161+mc1.20.1 (custom fork with sodium fix a changed version string for compat issues with this very mod) (#103)
Loader: Fabric Loader 0.15.3 + API 0.91.0

java.lang.NoClassDefFoundError: net/minecraft/client/world/ClientWorld
       at com.github.talrey.createdeco.blocks.CatwalkRailingBlock.onSneakWrenched(CatwalkRailingBlock.java:77) ~[createdeco-2.0.0-fabric-1.20.1.jar:?]
       at com.simibubi.create.content.equipment.wrench.WrenchItem.useOnBlock(WrenchItem.java:55) ~[create-sodium-fix-0.5.1-d-build.1161+mc1.20.1.jar:?]
       at net.minecraft.item.ItemStack.useOnBlock(ItemStack.java:272) ~[server-intermediary.jar:?]
       at net.minecraft.server.network.ServerPlayerInteractionManager.interactBlock(ServerPlayerInteractionManager.java:363) ~[server-intermediary.jar:?]
       at net.minecraft.server.network.ServerPlayNetworkHandler.onPlayerInteractBlock(ServerPlayNetworkHandler.java:1140) ~[server-intermediary.jar:?]
       at net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket.apply(PlayerInteractBlockC2SPacket.java:34) ~[server-intermediary.jar:?]
       at net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket.apply(PlayerInteractBlockC2SPacket.java:8) ~[server-intermediary.jar:?]
       at net.minecraft.network.NetworkThreadUtils.method_11072(NetworkThreadUtils.java:22) ~[server-intermediary.jar:?]
       at net.minecraft.server.ServerTask.run(ServerTask.java:18) ~[server-intermediary.jar:?]
       at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor.java:156) ~[server-intermediary.jar:?]
       at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor.java:23) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:782) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.executeTask(MinecraftServer.java:164) ~[server-intermediary.jar:?]
       at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor.java:130) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.runOneTask(MinecraftServer.java:14318) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.runTask(MinecraftServer.java:758) ~[server-intermediary.jar:?]
       at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor.java:139) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.runTasksTillTickEnd(MinecraftServer.java:743) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:675) ~[server-intermediary.jar:?]
       at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[server-intermediary.jar:?]
       at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.world.ClientWorld
       at jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) ~[?:?]
       at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
       at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:226) ~[fabric-loader-0.15.3.jar:?]
       at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:119) ~[fabric-loader-0.15.3.jar:?]
       at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
       ... 21 more```
       
       
       
commented

This is still happening to me today on my Fabric server, this mod is amazing but this is a massive flaw that needs to be fixed.

commented

Same configuration, same server crash. Seems to be caused by this check, (it looks like ClientLevel is not included in server jar)

if (level instanceof ClientLevel) return InteractionResult.PASS;

commented

Same configuration, same server crash. Seems to be caused by this check, (it looks like ClientLevel is not included in server jar)

if (level instanceof ClientLevel) return InteractionResult.PASS;

I've "solved" this myself compiling the jar myself after removing this line a few days ago as a "temporary solution" and running that on the server instead.

Not sure what it would break but at least it isn't crashing my server anymore and I'm just waiting for a proper fix.

commented

Not sure what it would break but at least it isn't crashing my server anymore and I'm just waiting for a proper fix.

It is only used as early exit condition for code, that should run only on server, so nothing would break, if you removed it only on server.

I never coded Minecraft mods and I have very little experience in java, but the solution would be to use another detection for whatever it is currently running on client or server. I tried to find some code snippet in other mods for fabric and forge, but I only found, that there is @Environment(EnvType.CLIENT) for fabric and @OnlyIn(Dist.CLIENT) for forge, for running certain functions only on client, but I didn't found some simple universal way to do so on both fabric and forge nor I wanted to dig into it mode...

commented

Shouldn't this test function exactly the same if it was if(level.isClientSide), but without the crash?
(if(level.isClient) for Yarn/Fabric mappings)

There are only two subclasses - ClientLevel and ServerLevel, and the test's job is to check whether the level is on the client.

Am I missing something, or is this just a simple mistake?

commented

Shouldn't this test function exactly the same if it was if(level.isClientSide), but without the crash? (if(level.isClient) for Yarn/Fabric mappings)

There are only two subclasses - ClientLevel and ServerLevel, and the test's job is to check whether the level is on the client.

Am I missing something, or is this just a simple mistake?

Yeah, this is exactly, what is changed in #120, which should fix it