Hi, i found that my gun that has a procedure "when bullet hits a block" and "when bullet hits entity" disconnects me. It does not crash the game, it just kicks me from the server.
I'm currently playing with my mod on 1.12.2
Here's the Error from my server log :
[22:43:24] [Netty Server IO #5/ERROR] [FML]: NetworkDispatcher exception
io.netty.handler.codec.EncoderException: java.lang.ArrayIndexOutOfBoundsException: 0
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:125) ~[MessageToByteEncoder.class:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) ~[AbstractChannelHandlerContext.class:?]
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.write(NetworkDispatcher.java:548) ~[NetworkDispatcher.class:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:801) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831) ~[AbstractChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1032) ~[DefaultChannelPipeline.class:?]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:296) ~[AbstractChannel.class:?]
at net.minecraft.network.NetworkManager$4.run(NetworkManager.java:245) [gw$4.class:?]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [AbstractEventExecutor.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) [SingleThreadEventExecutor.class:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442) [NioEventLoop.class:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at net.minecraft.network.play.server.SPacketParticles.func_148840_b(SourceFile:77) ~[jg.class:?]
at net.minecraft.network.NettyPacketEncoder.encode(NettyPacketEncoder.java:51) ~[ha.class:?]
at net.minecraft.network.NettyPacketEncoder.encode(NettyPacketEncoder.java:12) ~[ha.class:?]
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[MessageToByteEncoder.class:?]
... 18 more
[22:43:24] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: LEPRODOR lost connection: Internal Exception: io.netty.handler.codec.EncoderException: java.lang.ArrayIndexOutOfBoundsException: 0
[22:43:24] [Server thread/INFO] [minecraft/DedicatedServer]: LEPRODOR left the game
Issue comments
got it , i put it on mediafire since i use it a lot these times. so here it is : http://www.mediafire.com/file/i6381oegkjim5n3/Terraria_Mod_%2528to_send…
So when you will open the workspace, the buggy item is the "Bee Gun", it's going to be in the most recent adds to the mod. The procedure that apparently my server does not like is "when bullet hits entity" or "when bullet hits block" since it's the same procedure. (bee gun again)
- Wrap spawn particle procedure block with if statement that makes sure the current world is remote only (Is current world remote from World data category) as particles can only be spawned on the client-side
- When dealing with random chance, wrap the random chance if with another if that makes sure the world is not remote (so the procedure only runs on server side), otherwise you can end up with different random outcomes on server and client-side (not the cause of this crash, but still important thing to note)
I forgot to precise that it's a multiplayer server that gets this issue. It does not in solo mode. I did not test with other players if they get kicked out too tho. You can ask me more details if needed.