• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Probleme de packet

    1.7.x
    1.7.10
    3
    5
    1500
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • sosoh
      sosoh dernière édition par

      Bonjour j’ai fais une extended entity props. c’est une string, mais j’ai un probleme avec les packets qui permettent de synchroniser la string. Mes classes:

      [18:15:15] [Client thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught
      io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 64 (expected: range(0, 16))
      at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
      at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
      at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
      at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
      at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
      at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
      at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
      at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
      at net.minecraft.client.Minecraft.runTick(Minecraft.java:2141) [Minecraft.class:?]
      at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) [Minecraft.class:?]
      at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
      at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
      at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
      at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
      at GradleStart.main(Unknown Source) [start/:?]
      Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 64 (expected: range(0, 16))
      at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
      at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[SlicedByteBuf.class:?]
      at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
      at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[ByteBufUtils.class:?]
      at fr.sosoh.hogsmod.common.packet.PacketSpell1.fromBytes(PacketSpell1.java:29) ~[PacketSpell1.class:?]
      at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[SimpleIndexedCodec.class:?]
      at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?]
      at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
      at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
      at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
      at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
      … 19 more
      [18:15:15] [Client thread/ERROR] [FML]: There was a critical exception handling a packet on channel hogsmod
      io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: index: 1, length: 64 (expected: range(0, 16))
      at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?]
      at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
      at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
      at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
      at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
      at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
      at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
      at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
      at net.minecraft.client.Minecraft.runTick(Minecraft.java:2141) [Minecraft.class:?]
      at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) [Minecraft.class:?]
      at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
      at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
      at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
      at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
      at GradleStart.main(Unknown Source) [start/:?]
      Caused by: java.lang.IndexOutOfBoundsException: index: 1, length: 64 (expected: range(0, 16))
      at io.netty.buffer.AbstractByteBuf.checkIndex(AbstractByteBuf.java:1128) ~[AbstractByteBuf.class:?]
      at io.netty.buffer.SlicedByteBuf.nioBuffer(SlicedByteBuf.java:261) ~[SlicedByteBuf.class:?]
      at io.netty.buffer.AbstractByteBuf.toString(AbstractByteBuf.java:953) ~[AbstractByteBuf.class:?]
      at cpw.mods.fml.common.network.ByteBufUtils.readUTF8String(ByteBufUtils.java:119) ~[ByteBufUtils.class:?]
      at fr.sosoh.hogsmod.common.packet.PacketSpell1.fromBytes(PacketSpell1.java:29) ~[PacketSpell1.class:?]
      at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:17) ~[SimpleIndexedCodec.class:?]
      at cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec.decodeInto(SimpleIndexedCodec.java:7) ~[SimpleIndexedCodec.class:?]
      at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:77) ~[FMLIndexedMessageToMessageCodec.class:?]
      at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
      at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
      at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
      … 19 more
      
      ​package fr.sosoh.hogsmod.common.entity.props;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.EntityPlayerMP;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.world.World;
      import net.minecraftforge.common.IExtendedEntityProperties;
      import fr.sosoh.hogsmod.common.Hogsmod;
      import fr.sosoh.hogsmod.common.packet.PacketMana;
      import fr.sosoh.hogsmod.common.packet.PacketSpell1;
      import fr.sosoh.hogsmod.proxy.CommonProxy;
      
      public class ExtendedEntityProps implements IExtendedEntityProperties
      {
      
      public final static String EXT_PROP_NAME = "ExtHogs";
      
      private final EntityPlayer player;
      
      public double mana;
          public double maxMana;
          public String[] spellsList;
          public String spell1, spell2;
      
          public ExtendedEntityProps(EntityPlayer player) 
          {
      this.player = player;
      this.mana = 1000;
      this.maxMana = 1000;
      
      this.spell1 = "";
      this.spell2 = "";
      }
      
      @Override
      public void init(Entity entity, World world) 
      {
      
      }
      
      public static final void register(EntityPlayer player) 
      {
      player.registerExtendedProperties(ExtendedEntityProps.EXT_PROP_NAME,
      new ExtendedEntityProps(player));
      }
      
      public static final ExtendedEntityProps get(EntityPlayer player) 
      {
      return (ExtendedEntityProps) player.getExtendedProperties(EXT_PROP_NAME);
      }
      
      @Override
      public void saveNBTData(NBTTagCompound compound) 
      {
      
      NBTTagCompound properties = new NBTTagCompound();
      compound.setTag(EXT_PROP_NAME, properties);
      properties.setDouble("Mana", this.mana);
      properties.setDouble("MaxMana", this.maxMana);
      properties.setString("Spell1", this.spell1);
      properties.setString("Spell2", this.spell2);
      }
      
      @Override
      public void loadNBTData(NBTTagCompound compound) 
      {
      NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
      this.mana = properties.getDouble("Mana");
      this.maxMana = properties.getDouble("MaxMana");
      this.spell1 = properties.getString("Spell1");
      this.spell2 = properties.getString("Spell2");
      }
      
      public final void sync() 
      {
      PacketMana packetMana = new PacketMana(this.mana, this.maxMana);
      PacketSpell1 packetSpell1 = new PacketSpell1(this.spell1);
      
      if (!player.worldObj.isRemote) 
      {
      EntityPlayerMP player1 = (EntityPlayerMP) player;
      Hogsmod.network.sendTo(packetMana, player1);
      Hogsmod.network.sendTo(packetSpell1, player1);
      }
      }
      
      private static String getSaveKey(EntityPlayer player) 
      {
      return player.getDisplayName() + ":" + EXT_PROP_NAME;
      }
      
      public static void saveProxyData(EntityPlayer player) {
      ExtendedEntityProps playerData = ExtendedEntityProps.get(player);
      NBTTagCompound savedData = new NBTTagCompound();
      playerData.saveNBTData(savedData);
      CommonProxy.storeEntityData(getSaveKey(player), savedData);
      }
      
      public static void loadProxyData(EntityPlayer player) 
      {
      ExtendedEntityProps playerData = ExtendedEntityProps.get(player);
      NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player));
      
      if (savedData != null) 
      {
      playerData.loadNBTData(savedData);
      }
      playerData.sync();
      }
      
      public boolean removeMana(double amount) 
      {
      boolean sufficient = amount <= this.mana;
      
      if (sufficient) 
      {
      this.mana -= amount;
      this.sync();
      } else 
      {
      return false;
      }
      
      return sufficient;
      }
      
      public void addMana(double amount) 
      {
      this.mana += amount;
      this.sync();
      }
      
      public double getMana() 
      {
      return this.mana;
      }
      
      public void setMana(double newMana) 
      {
      this.mana = newMana;
      this.sync();
      }
      
      public double getMaxMana() {
      return this.maxMana;
      }
      
      public void setSpell1(String spell){
      this.spell1 = spell;
      this.sync();
      }
      
      public void setSpell2(String spell){
      this.spell2 = spell;
      this.sync();
      }
      
      public String getSpell1(){
      return this.spell1;
      }
      
      public String getSpell2(){
      return this.spell2;
      }
      }
      
      package fr.sosoh.hogsmod.common.packet;
      
      import io.netty.buffer.ByteBuf;
      import net.minecraft.entity.player.EntityPlayerMP;
      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 PacketSpell1 implements IMessage
      {
      
      private static String spell1;
      
      public PacketSpell1()
      {
      
      }
      
      public PacketSpell1(String spell)
      {
      this.spell1 = spell;
      }
      
      @Override
      public void fromBytes(ByteBuf buf) 
      {
      this.spell1 = ByteBufUtils.readUTF8String(buf);
      }
      
      @Override
      public void toBytes(ByteBuf buf) 
      {
      ByteBufUtils.writeUTF8String(buf, spell1);
      }
      public static class Handler implements IMessageHandler <packetspell1, imessage="">{
      
      @Override
      public IMessage onMessage(PacketSpell1 message, MessageContext ctx) 
      {
      EntityPlayerMP player = ctx.getServerHandler().playerEntity;
      ExtendedEntityProps props = ExtendedEntityProps.get(player);
      props.spell1 = spell1;
      return null;
      }
      
      }
      }
      
      @EventHandler
      
      public void preInit(FMLPreInitializationEvent event)
      {
      itemElderWand = new ItemElderWand().setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("elderwand");
      GameRegistry.registerItem(itemElderWand, "item_elderwand");
      
      network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
      network.registerMessage(PacketMana.Handler.class, PacketMana.class, 2, Side.SERVER);
      network.registerMessage(PacketSpell1.Handler.class, PacketSpell1.class, 2, Side.SERVER);
      }
      ```</packetspell1,>

      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

        Je viens de comprendre le problème. Tu as enregistré deux paquets avec le même discriminateur. Du-coup ça fou la merde.
        (        network.registerMessage(PacketMana.Handler.class, PacketMana.class, 2, Side.SERVER); remplace 2 par 1 ici)

        1 réponse Dernière réponse Répondre Citer 0
        • sosoh
          sosoh dernière édition par

          Ah ok merci ! 😄 C’est pas moi qui ai fait le systeme pour les packets la 1ere fois et je ne maitrise pas… Mais c’est quoi un discriminateur ? ^^

          Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

          1 réponse Dernière réponse Répondre Citer 0
          • Deleted
            Deleted dernière édition par

            @‘sosoh’:

            Ah ok merci ! 😄 C’est pas moi qui ai fait le systeme pour les packets la 1ere fois et je ne maitrise pas… Mais c’est quoi un discriminateur ? ^^

            Bah tant qu’à faire tu peux dire que c’est moi qui l’ai fait x)
            Et pour répondre à ta question un discriminateur c’est une sorte d’id pour les packets.

            1 réponse Dernière réponse Répondre Citer 0
            • sosoh
              sosoh dernière édition par

              id* 😛 et merci 😉 (PS: je commece le systeme pour gerer les sorts, la selection etc…)

              Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

              1 réponse Dernière réponse Répondre Citer 0
              • 1 / 1
              • Premier message
                Dernier message
              Design by Woryk
              Contact / Mentions Légales

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB