Hello everyone,
I have the problem, that "world.playSound", called by a onItemRightClick event only works on the client side and doesn't work if send to the clients over the server.
If I use
worldIn.playSound(playerIn, playerIn.getPosition(), DifficultyModRegister.glock18_sound, difficultyModSound, 1.0F, 1.0F);
it works in the singleplayer and also for the client shooting, but if somebody is standing near by or if I replace the first playerIn with null, you
are getting disconnected from the server when shooting. I have allready read the sounds documentation and I haven't found anything, that could be wrong.
The error is as followed every time:
[16:20:51] [Netty Client IO #6/ERROR] [FML]: NetworkDispatcher exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(3) + length(1) exceeds writerIndex(3): UnpooledHeapByteBuf(ridx: 3, widx: 3, cap: 3)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:280) ~[byteToMessageDecoder.class:4.0.23.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:149) ~[byteToMessageDecoder.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) [byteToMessageDecoder.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) [byteToMessageDecoder.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:150) [ReadTimeoutHandler.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787) [DefaultChannelPipeline.class:4.0.23.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130) [AbstractNioByteChannel$NioByteUnsafe.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [NioEventLoop.class:4.0.23.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [singleThreadEventExecutor$2.class:4.0.23.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(3) + length(1) exceeds writerIndex(3): UnpooledHeapByteBuf(ridx: 3, widx: 3, cap: 3)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1175) ~[AbstractByteBuf.class:4.0.23.Final]
at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:570) ~[AbstractByteBuf.class:4.0.23.Final]
at net.minecraft.network.PacketBuffer.readByte(PacketBuffer.java:792) ~[PacketBuffer.class:?]
at net.minecraft.network.PacketBuffer.readVarInt(PacketBuffer.java:215) ~[PacketBuffer.class:?]
at net.minecraft.network.PacketBuffer.readEnumValue(PacketBuffer.java:196) ~[PacketBuffer.class:?]
at net.minecraft.network.play.server.SPacketSoundEffect.readPacketData(SPacketSoundEffect.java:45) ~[sPacketSoundEffect.class:?]
at net.minecraft.network.NettyPacketDecoder.decode(NettyPacketDecoder.java:38) ~[NettyPacketDecoder.class:?]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:249) ~[byteToMessageDecoder.class:4.0.23.Final]
... 20 more
I don't know what exactly is causing the index out of bounds exception and I would be happy if any one can help me with that problem.
[solved]
I have used the wrong sound category now I am using SoundCategory.MASTER and everything works fine.