Topic category: Troubleshooting, bugs, and solutions
Hi everyone,
I'm working on a Minecraft mod using MCreator and NeoForge 1.20.4. I've created a custom GUI and implemented an on-tick procedure to check the inputs and enable or disable buttons accordingly.
The issue arises when I press a button in the GUI. The game crashes, and the error message indicates a ClassCastException. Removing the on-tick procedure seems to fix the crash, but I need this procedure to function correctly. Here is the relevant error message:
[02:32:12] [Netty Server IO #1/ERROR] [minecraft/Connection]: Received class net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket that couldn't be processed
java.lang.ClassCastException: class ....network.OverviewGUIButtonMessage cannot be cast to class ....world.inventory.OverviewGUIMenu$OverviewGUIOtherMessage (....network.OverviewGUIButtonMessage and ....world.inventory.OverviewGUIMenu$OverviewGUIOtherMessage are in module testmod@1.0.0 of loader 'TRANSFORMER' @4f8d86e4)
...
[02:32:12] [Server thread/INFO] [minecraft/ServerGamePacketListenerImpl]: Dev lost connection: Server sent an invalid packetI want to note that this is not due to the button press procedure as even if its empty it still crashes, this happened to me with also another mod where I had an on effect active tick procedure but when I cleared the effect it crashed, however just letting it expire naturally doesnt crash it, just like closing this gui with esc also doesnt crash it.