Résolu [1.12.2] crash paquet
-
Bonjours, j’ai un crash a l’utilisation d’un paquet que je ne comprend pas :
[09:34:31] [main/INFO] [STDOUT]: [fr.chokearth.dog.util.base_network.PacketAskUpdate:toBytes:41]: phase 1 1 2 3 [09:34:31] [Netty Server IO #1/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(12) + length(4) exceeds writerIndex(12): UnpooledSlicedByteBuf(ridx: 12, widx: 12, cap: 12/12, unwrapped: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 13, cap: 256)) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98) ~[MessageToMessageDecoder.class:4.1.9.Final] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) [EmbeddedChannel.class:4.1.9.Final] at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?] at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleServerSideCustomPacket(NetworkDispatcher.java:456) [NetworkDispatcher.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:268) [NetworkDispatcher.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final] at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final] at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final] at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [AbstractEventExecutor.class:4.1.9.Final] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) [SingleThreadEventExecutor.class:4.1.9.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442) [NioEventLoop.class:4.1.9.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92] Caused by: java.lang.IndexOutOfBoundsException: readerIndex(12) + length(4) exceeds writerIndex(12): UnpooledSlicedByteBuf(ridx: 12, widx: 12, cap: 12/12, unwrapped: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 13, cap: 256)) at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1396) ~[AbstractByteBuf.class:4.1.9.Final] at io.netty.buffer.AbstractByteBuf.readInt(AbstractByteBuf.java:766) ~[AbstractByteBuf.class:4.1.9.Final] at fr.chokearth.dog.metier.leatherworks.network.PacketUpdateBarrel.fromBytes(PacketUpdateBarrel.java:39) ~[PacketUpdateBarrel.class:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:36) ~[SimpleIndexedCodec.class:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:26) ~[SimpleIndexedCodec.class:?] at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:101) ~[FMLIndexedMessageToMessageCodec.class:?] at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:38) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:4.1.9.Final] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[MessageToMessageDecoder.class:4.1.9.Final] ... 35 more
Le Packet PacketAskUpdate :
package fr.chokearth.dog.util.base_network; import fr.chokearth.dog.util.inter.INetworkUpdatable; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class PacketAskUpdate implements IMessage { private int x; private int y; private int z; public PacketAskUpdate(){} public PacketAskUpdate(int x, int y, int z){ this.x = x; this.y = y; this.z = z; } @Override public void fromBytes(ByteBuf buf) { System.out.println("phase 2"); this.x = buf.readInt(); System.out.println("1"); this.y = buf.readInt(); System.out.println("2"); this.z = buf.readInt(); System.out.println("3"); } @Override public void toBytes(ByteBuf buf) { System.out.println("phase 1"); buf.writeInt(this.x); System.out.println(1); buf.writeInt(this.y); System.out.println(2); buf.writeInt(this.z); System.out.println(3); } public static class Handler implements IMessageHandler<PacketAskUpdate, IMessage> { @SideOnly(Side.SERVER) @Override public IMessage onMessage(PacketAskUpdate message, MessageContext ctx) { System.out.println("oui"); INetworkUpdatable obg = (INetworkUpdatable) Minecraft.getMinecraft().world.getTileEntity(new BlockPos(message.x, message.y, message.z)); if (obg != null){ obg.networkUpdate(ctx.getServerHandler().player); } return null; } } }
La fonction où il est appelé :
public void setFill(int fill) { this.fill = fill; if (world.isRemote) { NetworkHandler.network.sendToServer(new PacketAskUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ())); } }
NetworkHandler :
package fr.chokearth.dog.util.handler; import fr.chokearth.dog.metier.leatherworks.network.PacketUpdateBarrel; import fr.chokearth.dog.object.block.toc_toc.network.PacketTocTocAskInfo; import fr.chokearth.dog.object.block.toc_toc.network.PacketTocTocInfo; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; public class NetworkHandler { public static SimpleNetworkWrapper visualAnimation; public static SimpleNetworkWrapper network; public static SimpleNetworkWrapper leatherworks; public static void packetInit(){ visualAnimation = NetworkRegistry.INSTANCE.newSimpleChannel("DOG_VisualAnimation"); //visualAnimation.registerMessage(PacketTocTocAskInfo.Handler.class, PacketTocTocAskInfo.class, 0, Side.SERVER); //visualAnimation.registerMessage(PacketTocTocInfo.Handler.class, PacketTocTocInfo.class, 1, Side.CLIENT); network = NetworkRegistry.INSTANCE.newSimpleChannel("DOG_BaseNetwork"); network.registerMessage(PacketUpdateBarrel.Handler.class, PacketUpdateBarrel.class, 0, Side.SERVER); leatherworks = NetworkRegistry.INSTANCE.newSimpleChannel("DOG_Leatherworks"); leatherworks.registerMessage(PacketUpdateBarrel.Handler.class, PacketUpdateBarrel.class, 0, Side.CLIENT); } }
Je ne trouve vraiment pas la solution…
Merci de votre aide. -
Salut,
Je ne vois pas où tu enregistre ton packet PacketAskUpdate dans le NetworkHandler.
Je ne vois pas non plus la pertinence d’avoir autant de canaux. -
A oui, j’ai enregistré 2 fois PacketUpdateBarrel, et pour le nombre de canaux j’ai :
- visualAnimation pour les infos d’animation TESR
- network pour les paquets qui peuvent être utiliser pour plusieurs chose
- et après j’aurai un canal par métier et la je suis sur le métier du travailleur de cuir
J’ai un nouveau crash mais je vais d’abord voir si je peux trouver moi même.