[1.7.2 ++] Le network
-
J’avais pensais à çà aussi robin mais j’ai une erreur ….
public class Packetteleport implements IMessage { private static String text; public Packetteleport () { } public Packetteleport (String text) { this.text = text; } @Override public void fromBytes(ByteBuf buf) { text = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, text); } public static class Handler implements IMessageHandler <packetteleport ,="" imessage="">{ @Override public IMessage onMessage(Packetteleport message, MessageContext ctx) { switch(text) { case "gui1": System.out.println("Bonjour monsieur !"); player.setPositionAndUpdate(-22, 37, -694); break; case "gui2": System.out.println("Bonsoir monsieur !"); break; } return null; } } }
J’ai une erreur sur le player.setPositionAndUpdate(-22, 37, -694);</packetteleport>
-
Normal, il faut récupérer l’instance du joueur x)
Remplace player par ctx.getServerHandler().playerEntity -
Oui je sais qu’il faut récupérer l’instance j’ai essayer plein de chose, mais je n’est rien trouvé de concluant mais tu viens de me sauver la vie .
Merci beaucoup
ROBIN IS GOD!!!
-
Salut je ne trouves pas comment faire des packets avec ma List <string>voila ma classe de packet:
public class PacketSpellsList implements IMessage { private static List <string>spellsList = new ArrayList<string>(); public PacketSpellsList() { } public PacketSpellsList(List <string>spellsList) { this.spellsList = spellsList; } @Override public void fromBytes(ByteBuf buf) { } @Override public void toBytes(ByteBuf buf) { } public static class Handler implements IMessageHandler <packetmana, imessage="">{ @Override public IMessage onMessage(PacketMana message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; ExtendedEntityProps props = ExtendedEntityProps.get(player); props.spellsList = spellsList; return null; } } } ```</packetmana,></string></string></string></string>
-
@‘sosoh’:
Salut je ne trouves pas comment faire des packets avec ma List <string>voila ma classe de packet:
public class PacketSpellsList implements IMessage { private static List <string>spellsList = new ArrayList<string>(); public PacketSpellsList() { } public PacketSpellsList(List <string>spellsList) { this.spellsList = spellsList; } @Override public void fromBytes(ByteBuf buf) { } @Override public void toBytes(ByteBuf buf) { } public static class Handler implements IMessageHandler <packetmana, imessage="">{ @Override public IMessage onMessage(PacketMana message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; ExtendedEntityProps props = ExtendedEntityProps.get(player); props.spellsList = spellsList; return null; } } } ```</packetmana,></string></string></string></string>
-
En effet je l’ai expliqué dans le tutoriel vidéo.
toBytes :
Tu écrit la taille de la liste
Avec une boucle for tu initialise la liste.
fromBytes :
Tu lis la taille de la liste
Avec une boucle for de 0 au nombre lu juste avant, tu ajoute à la liste ce que tu lis. -
J’ai fais ca:
package fr.sosoh.hogsmod.common.packet; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps; public class PacketSpellsList implements IMessage { private static List <string>spellsList; public PacketSpellsList() { } public PacketSpellsList(List <string>spellsList) { this.spellsList = spellsList; } @Override public void fromBytes(ByteBuf buf) { for(int i = 0; i < spellsList.size(); i++) { String s = spellsList.get(i); if(s != null) { ByteBufUtils.writeUTF8String(buf, s); } } } @Override public void toBytes(ByteBuf buf) { for(int i = 0; i < spellsList.size(); i++) { this.spellsList.add(ByteBufUtils.readUTF8String(buf)); } } public static class Handler implements IMessageHandler <packetspellslist, imessage="">{ @Override public IMessage onMessage(PacketSpellsList message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; ExtendedEntityProps props = ExtendedEntityProps.get(player); props.spellsList = spellsList; return null; } } }
et j’ai des erreurs dans mes logs:
[17:13:03] [Server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more avr. 16, 2015 5:13:03 PM io.netty.channel.embedded.EmbeddedChannel recordException AVERTISSEMENT: More than one exception was raised. Will report only the first one and log others. io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ... 23 more ```</packetspellslist,></string></string>
-
@‘sosoh’:
J’ai fais ca:
package fr.sosoh.hogsmod.common.packet; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps; public class PacketSpellsList implements IMessage { private static List <string>spellsList; public PacketSpellsList() { } public PacketSpellsList(List <string>spellsList) { this.spellsList = spellsList; } @Override public void fromBytes(ByteBuf buf) { for(int i = 0; i < spellsList.size(); i++) { String s = spellsList.get(i); if(s != null) { ByteBufUtils.writeUTF8String(buf, s); } } } @Override public void toBytes(ByteBuf buf) { for(int i = 0; i < spellsList.size(); i++) { this.spellsList.add(ByteBufUtils.readUTF8String(buf)); } } public static class Handler implements IMessageHandler <packetspellslist, imessage="">{ @Override public IMessage onMessage(PacketSpellsList message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; ExtendedEntityProps props = ExtendedEntityProps.get(player); props.spellsList = spellsList; return null; } } }
et j’ai des erreurs dans mes logs:
[17:13:03] [Server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more [17:13:03] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) ~[DefaultChannelPipeline.class:?] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) ~[AbstractChannel.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) [SimpleNetworkWrapper.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) [ExtendedEntityProps.class:?] at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) [ItemElderWand.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) [ItemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) [ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) [C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) ~[AbstractByteBuf.class:?] at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) ~[ByteBufUtils.class:?] at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) ~[PacketSpellsList.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:?] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:?] … 23 more avr. 16, 2015 5:13:03 PM io.netty.channel.embedded.EmbeddedChannel recordException AVERTISSEMENT: More than one exception was raised. Will report only the first one and log others. io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644) at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698) at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:688) at io.netty.channel.DefaultChannelHandlerContext.writeAndFlush(DefaultChannelHandlerContext.java:717) at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:893) at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:239) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:196) at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.sync(ExtendedEntityProps.java:121) at fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps.setSpellsList(ExtendedEntityProps.java:207) at fr.sosoh.hogsmod.common.items.ItemElderWand.onItemRightClick(ItemElderWand.java:25) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:345) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:576) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) Caused by: java.lang.IndexOutOfBoundsException: readerIndex: 5 (expected: 0 <= readerIndex <= writerIndex(1)) at io.netty.buffer.AbstractByteBuf.readerIndex(AbstractByteBuf.java:72) at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:120) at fr.sosoh.hogsmod.common.packet.PacketSpellsList.toBytes(PacketSpellsList.java:51) at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:51) at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ... 23 more ```</packetspellslist,></string></string>
Tu as inversé les fonctions toBytes et fromBytes : toBytes (doit être writeUTF8String), fromBytes (doit être readUTF8String)
-
Et même en inversant tu vas avoir un npe sur la lecture du paquet, car ta liste sera null. Il faut l’initialiser, après comme sa taille fera 0, ta boucle ne va pas fonctionner …
C’est pas pour rien que j’ai dit qu’il faut écrire et lire la taille de la liste. -
J’ai pas compris ce que je dois faire
-
@‘sosoh’:
J’ai pas compris ce que je dois faire
La fonction toBytes est l’écriture des tes variables sous formes de bytes :
1-écrire la taille de taille de ta liste (il est d’ailleurs plus préférable d’utiliser une array plutôt qu’une liste);
2-écrire tous les textes avec une boucle for.La fonction fromBytes est la lecture de tes variables à partir de bytes:
1-lire la taille de ta liste;
2-Lire tous les String en fonction de la taille lue précédemment. -
Qu’est-il advenu de AbstractMetroidPacket en 1.8 ?
-
Elle sert à quoi cette classe ?
-
Petit déterrage, mais je crois qu’on a le droit pour un tuto. Je ne suis pas là pour demander de l’aide mais pour proposer un example concret car au début (quand Blackout m’a référencé son tuto) je ne comprenais absolument rien. Donc mon example serait tout simplement faire exécuter une commande au serveur à partir du client (GUI).
-
Oui mais le but du tutoriel c’est d’utiliser les paquets, or ce que tu dis là c’est possible sans faire de paquets customs
-
Oui, mais c’est un example quand même de le faire avec un packet custom.
-
Oui mais inutile, or Robin a fait un tuto vidéo dans lequel tout est expliqué
-
Oui, mais ça concrétise quand même l’utilisation d’un packet. Ah oui, c’est pas faut pour la vidéo de robin.
-
Si je montre comment faire une commande avec des paquets certains vont le faire dans leur mod alors qu’il ne faut pas utiliser les paquets pour les commandes. Certes, ce serait une illustration, mais pas un exemple
-
Je proposerais bien l’exemple d’un packet pour pouvoir utiliser une touche personnalisée parce que j’essaie de comprendre l’utilisation des packets, mais là je suis dans le potage complet.
Bon exemple comme le Keyboard est uniquement côté Client, nan? ^^’