CC: Tweaked

CC: Tweaked

59M Downloads

Right-clicking turtle (probably computers in general) while in spectator mode soft crashes the game

Zirunis opened this issue ยท 2 comments

commented

Minecraft Version

1.20.x

Version

1.110.3

Details

The title says it all. Let me clarify what I mean by "soft crash": The world seems to shutdown graciously (without corrupting the world save) and I land back in the minecraft main menu. Interestingly I land there in the server section with a "Connection Lost: Network Protocol Error" even though it's a normal single player world. I attached a screenshot and below are the logs.
spectate_bug

Logs
[28May2024 01:59:53.964] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Zirunis joined the game
[28May2024 01:59:54.070] [Render thread/INFO] [net.minecraft.advancements.AdvancementTree/]: Loaded 172 advancements
[28May2024 01:59:55.138] [Render thread/ERROR] [net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl/]: Failed to handle packet net.minecraft.network.protocol.game.ClientboundOpenScreenPacket@44143892
java.lang.NullPointerException: Cannot invoke "net.minecraft.network.FriendlyByteBuf.readEnum(java.lang.Class)" because "buffer" is null
  at TRANSFORMER/[email protected]/dan200.computercraft.shared.network.codec.MoreStreamCodecs$1.decode(MoreStreamCodecs.java:29) ~[cc-tweaked-1.20.5-forge-1.110.3.jar%23186!/:1.110.3]
  at TRANSFORMER/[email protected]/dan200.computercraft.shared.network.codec.MoreStreamCodecs$1.decode(MoreStreamCodecs.java:26) ~[cc-tweaked-1.20.5-forge-1.110.3.jar%23186!/:1.110.3]
  at TRANSFORMER/[email protected]/net.minecraft.network.codec.StreamCodec$10.decode(StreamCodec.java:196) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/dan200.computercraft.shared.platform.PlatformHelperImpl.lambda$createMenuType$0(PlatformHelperImpl.java:122) ~[cc-tweaked-1.20.5-forge-1.110.3.jar%23186!/:1.110.3]
  at TRANSFORMER/[email protected]/net.neoforged.neoforge.network.IContainerFactory.create(IContainerFactory.java:18) ~[neoforge-20.5.21-beta-universal.jar%23188!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.world.inventory.MenuType.create(MenuType.java:54) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.gui.screens.MenuScreens$ScreenConstructor.fromPacket(MenuScreens.java:126) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.gui.screens.MenuScreens.lambda$create$0(MenuScreens.java:44) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[?:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.gui.screens.MenuScreens.create(MenuScreens.java:44) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.multiplayer.ClientPacketListener.handleOpenScreen(ClientPacketListener.java:1241) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.network.protocol.game.ClientboundOpenScreenPacket.handle(ClientboundOpenScreenPacket.java:38) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.network.protocol.game.ClientboundOpenScreenPacket.handle(ClientboundOpenScreenPacket.java:13) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:25) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:111) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.runTick(Minecraft.java:1216) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.run(Minecraft.java:815) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at TRANSFORMER/[email protected]/net.minecraft.client.main.Main.main(Main.java:244) ~[client-1.20.5-20240423.152201-srg.jar%23187!/:?]
  at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
  at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
  at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:127) ~[loader-3.0.18.jar%23101!/:3.0]
  at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:115) ~[loader-3.0.18.jar%23101!/:3.0]
  at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonClientLaunchHandler.runService(CommonClientLaunchHandler.java:29) ~[loader-3.0.18.jar%23101!/:3.0]
  at MC-BOOTSTRAP/[email protected]/net.neoforged.fml.loading.targets.CommonLaunchHandler.lambda$launchService$4(CommonLaunchHandler.java:109) ~[loader-3.0.18.jar%23101!/:3.0]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:103) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:74) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-10.1.10.jar%23103!/:?]
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-10.1.10.jar%23103!/:?]
  at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) [bootstraplauncher-1.1.2.jar:?]
[28May2024 01:59:55.185] [Server thread/INFO] [net.minecraft.server.network.ServerGamePacketListenerImpl/]: Zirunis lost connection: Disconnected
[28May2024 01:59:55.185] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Zirunis left the game
[28May2024 01:59:55.194] [Server thread/INFO] [net.minecraft.server.network.ServerCommonPacketListenerImpl/]: Stopping singleplayer server as player logged out
[28May2024 01:59:55.239] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Stopping server
[28May2024 01:59:55.239] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving players
[28May2024 01:59:55.239] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving worlds
[28May2024 01:59:55.626] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving chunks for level 'ServerLevel[CC-Dev]'/minecraft:overworld
[28May2024 01:59:56.496] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving chunks for level 'ServerLevel[CC-Dev]'/minecraft:the_nether
[28May2024 01:59:56.500] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving chunks for level 'ServerLevel[CC-Dev]'/minecraft:the_end
[28May2024 01:59:56.506] [Server thread/DEBUG] [net.neoforged.neoforge.common.CommonHooks/WP]: Gathered mod list to write to world save CC-Dev
[28May2024 01:59:56.509] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: ThreadedAnvilChunkStorage (CC-Dev): All chunks are saved
[28May2024 01:59:56.509] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[28May2024 01:59:56.509] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[28May2024 01:59:56.509] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: ThreadedAnvilChunkStorage: All dimensions are saved
[28May2024 01:59:57.526] [Server thread/DEBUG] [net.neoforged.fml.config.ConfigTracker/CONFIG]: Unloading configs type SERVER
[28May2024 01:59:57.597] [Render thread/WARN] [net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl/]: Client disconnected with reason: Network Protocol Error
commented

Thanks for the report! The issue here is that spectator mode directly opens a block's menu, rather than going through the right click hook. This means that we don't open the block with any of the custom data we need (i.e. terminal contents).

This might be possible to work around within Fabric (where their menu hooks are a little more powerful), but not for Forge. I think for now I'll just remove the code that enables spectators to open menus.

commented

Sounds like a sufficient solution to me. Especially with /computercraft track dump allowing to open a turtles' display this functionality isn't very important. Thank you for the quick fix!