MarkusBordihn / BOs-Easy-NPC

Create easily NPC for your world or for your mod.
Other
19 stars 7 forks source link

[Bug] "Cannot send packets when not in game" #317

Closed Immorikal closed 3 weeks ago

Immorikal commented 3 weeks ago

πŸ’‘ Check the Bug Tracker and Crash Tracker before reporting a new issue. There you can find a lot of useful information and solutions for common problems.

Note: Please make sure to fill out the following template to the best of your ability. This will help us to identify and fix the issue faster.

Minecraft and Mod version 🐞 The used Minecraft and Mod version. 1.20.1 - EasyNPC v5.58 - Fabric Version (Loader: 0.16.2)

Describe the bug 🐞 A clear and concise description of what the bug is.

To Reproduce βš™οΈ Steps to reproduce the behavior:

Expected behavior βœ”οΈ A clear and concise description of what you expected to happen.

Screenshots πŸ“Έ If applicable, add screenshots to help explain your problem.

Debugging πŸ› οΈ Before reporting an issue, please enable the debug mode over /easy_npc debug true to get more detailed information about the issue in the logs. Additionally, check if there is anything relevant in the crash-reports, debug.log, and latest.log file.

Log Snippet taken directly from my Prism Launcher console: [05:15:42] [Netty Local Client IO #1/ERROR]: Exception occurred in netty pipeline java.lang.IllegalStateException: Cannot send packets when not in game! at net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.send(ClientPlayNetworking.java:370) ~[fabric-networking-api-v1-1.3.11+1802ada577-a65c3ef3908d32fd.jar:?] at de.markusbordihn.easynpc.network.NetworkHandler.sendToServer(NetworkHandler.java:50) ~[easy_npc-fabric-1.20.1-5.5.8.jar:?] at de.markusbordihn.easynpc.network.NetworkHandlerManager.sendToServer(NetworkHandlerManager.java:94) ~[easy_npc-fabric-1.20.1-5.5.8.jar:?] at de.markusbordihn.easynpc.network.message.ServerNetworkMessageHandlerInterface.openMenu(ServerNetworkMessageHandlerInterface.java:310) ~[easy_npc-fabric-1.20.1-5.5.8.jar:?] at de.markusbordihn.easynpc.network.message.client.OpenMenuCallbackMessage.handleClient(OpenMenuCallbackMessage.java:82) ~[easy_npc-fabric-1.20.1-5.5.8.jar:?] at de.markusbordihn.easynpc.network.NetworkHandler.lambda$registerClientNetworkMessageHandler$0(NetworkHandler.java:76) ~[easy_npc-fabric-1.20.1-5.5.8.jar:?] at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.receive(ClientPlayNetworkAddon.java:98) ~[fabric-networking-api-v1-1.3.11+1802ada577-a65c3ef3908d32fd.jar:?] at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.receive(ClientPlayNetworkAddon.java:40) ~[fabric-networking-api-v1-1.3.11+1802ada577-a65c3ef3908d32fd.jar:?] at net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon.handle(AbstractChanneledNetworkAddon.java:101) ~[fabric-networking-api-v1-1.3.11+1802ada577-a65c3ef3908d32fd.jar:?] at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.handle(ClientPlayNetworkAddon.java:90) ~[fabric-networking-api-v1-1.3.11+1802ada577-a65c3ef3908d32fd.jar:?] at net.minecraft.class_634.handler$fbm000$fabric-networking-api-v1$handleCustomPayload(class_634.java:4268) ~[client-intermediary.jar:?] at net.minecraft.class_634.method_11152(class_634.java) ~[client-intermediary.jar:?] at net.minecraft.class_2658.method_11457(class_2658.java:60) ~[client-intermediary.jar:?] at net.minecraft.class_2658.method_11054(class_2658.java:8) ~[client-intermediary.jar:?] at net.minecraft.class_2535.method_10759(class_2535.java:175) ~[client-intermediary.jar:?] at net.minecraft.class_2535.method_10770(class_2535.java:160) ~[client-intermediary.jar:?] at net.minecraft.class_2535.channelRead0(class_2535.java:52) ~[client-intermediary.jar:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.local.LocalChannel.readInbound(LocalChannel.java:299) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:445) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.local.LocalChannel.access$400(LocalChannel.java:50) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:403) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.82.Final.jar:?] at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-transport-4.1.82.Final.jar:?] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.82.Final.jar:?] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.82.Final.jar:?] at java.lang.Thread.run(Thread.java:842) ~[?:?]

Is the issue happening in combination with other mods? (If yes, please provide a full list) 🧩

List: https://pastebin.com/8pV6LLLn

Additional context πŸ“ Add any other context about the problem here.

MarkusBordihn commented 3 weeks ago

Thank you for the report. I've added a safety check that should prevent this error after a crash.

The issue occurs because the client attempts to send a package that is still queued during game startup, leading to this error message and an additional crash.

In version 5.5.9, we've implemented double-checks to ensure the connection is still valid, which should prevent the client from crashing if any errors occur.

Please let me know if this resolves the issue. Thanks!