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

Résolu Problème de GUI

Anciennes versions
1.6.4
4
48
13.4k
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.
  • Gugu
    Gugu dernière édition par 24 janv. 2014, 20:08

    Envoie le “vrai” crash log si possible 🙂

    "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
    ― Jordan B. Peterson

    1 réponse Dernière réponse Répondre Citer 0
    • EclipseOnFire
      EclipseOnFire dernière édition par 24 janv. 2014, 20:14

      @‘Gugu42’:

      Envoie le “vrai” crash log si possible 🙂

      ^^ C’est exactement le même. Je le met quand même :

      Une erreur est survenue : 'null', null
      2014-01-24 21:11:05 [Infos] [STDERR] java.io.EOFException
      2014-01-24 21:11:05 [Infos] [STDERR] at java.io.DataInputStream.readChar(DataInputStream.java:365)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.packet.Packet.readString(Packet.java:231)
      2014-01-24 21:11:05 [Infos] [STDERR] at fr.wirestone.PacketHandler.handleSoundBlockPacket(PacketHandler.java:29)
      2014-01-24 21:11:05 [Infos] [STDERR] at fr.wirestone.PacketHandler.onPacketData(PacketHandler.java:19)
      2014-01-24 21:11:05 [Infos] [STDERR] at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:255)
      2014-01-24 21:11:05 [Infos] [STDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)
      2014-01-24 21:11:05 [Infos] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:85)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.NetServerHandler.handleCustomPayload(NetServerHandler.java:1130)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
      2014-01-24 21:11:05 [Infos] [STDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
      

      Travaille sur un super serveur, Wirestone.

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 24 janv. 2014, 21:58

        Le String que tu as envoyé est null, il faudrait lui mettre une valeur par défaut.
        Tu es sur du “packet.readString(data,200);” ?

        1 réponse Dernière réponse Répondre Citer 0
        • EclipseOnFire
          EclipseOnFire dernière édition par 25 janv. 2014, 11:31

          J’ai moi même recrée les deux méthodes (writeString() et readString()) et j’obtiens la même erreur.
          En examinant les bytes avec des System.out.println(), j’ai pu voir que les coordonnées n’étaient pas présentes et que ma méthode donnait la longueur à partir de 0 et non de 1, ce qui provoquait une erreur dans ma méthode. J’ai corrigé le problème. Voici mes deux méthodes (pleinement opérationnelles), pour ceux qui auraient le même problème :

          /**
          * Permet d'écrire une chaîne de caractères dans un DataOutputStream
          * @param stream - Le DataOutputStream
          * @param str - La chaîne à écrire
          * @see readString()
          */
          public static void writeString(DataOutputStream stream, String str) throws IOException{
          char[] chrs = str.toCharArray();
          stream.writeShort(chrs.length - 1);
          for(char i : chrs){
          stream.writeChar(i);
          }
          }
          /**
          * Permet de récupérer une chaîne de caractères formée avec la méthode `writeString()`
          * @param stream - Le DataInputStream
          * @return str- La chaîne de caractère lue
          * @see writeString()
          */
          public static String readString(DataInputStream stream) throws IOException{
          short lenght = stream.readShort();
          String str = "";
          for(short i = 0; i<=lenght; i++){
          str += stream.readChar();
          }
          return str;
          }

          Bref maintenant je n’ai plus d’erreurs, sauf que les valeurs de mes boutons ne s’initialisent pas correctement, (en fait elles ne s’initialisent pas du tout), comme si mon DataInputStream n’avait aucun effet… T_T
          GuiSoundBlock.java

          @SideOnly(Side.CLIENT)
          public class GuiSoundBlock extends GuiContainer{
          public static ResourceLocation texture = new ResourceLocation("wsmod", "gui/soundBlock.png");
          private ArrayList <string>soundList = new ArrayList<string>();
          private TileEntitySoundBlock soundBlock;
          private int volume = 50, range = 50, delay = 50, x, y;
          private GuiTextField soundChooser;
          private String sound = "wsmod:alarm-default";
          private Logger logger;
          public GuiSoundBlock(InventoryPlayer inventory, TileEntitySoundBlock tile){
          super(new ContainerSoundBlock(inventory, tile));
          this.logger = WirestoneModLogger.getLogger();
          this.soundBlock = tile;
          this.xSize = 255;
          this.ySize = 255;
          this.soundList = Registry.soundList;
          this.volume = (int)tile.getVolume() * 100;
          }
          @Override
          public void initGui(){
          super.initGui();
          //Initialisation des variables
          this.x = (this.width) / 2;
          this.y = (this.height - this.ySize) / 2;
          this.buttonList.clear();
          //Selecteur de volume
          this.buttonList.add(new GuiButton(1, x + 60, y + 40, 20, 20, "+"));
          this.buttonList.add(new GuiButton(2, x + 80, y + 40, 20, 20, "++"));
          this.buttonList.add(new GuiButton(3, x - 80, y + 40, 20, 20, "-"));
          this.buttonList.add(new GuiButton(4, x - 100, y + 40, 20, 20, "--"));
          //Selecteur de portée
          this.buttonList.add(new GuiButton(5, x + 60, y + 80, 20, 20, "+"));
          this.buttonList.add(new GuiButton(6, x + 80, y + 80, 20, 20, "++"));
          this.buttonList.add(new GuiButton(7, x - 80, y + 80, 20, 20, "-"));
          this.buttonList.add(new GuiButton(8, x - 100, y + 80, 20, 20, "--"));
          //Selecteur de délai
          this.buttonList.add(new GuiButton(9, x + 60, y + 120, 20, 20, "+"));
          this.buttonList.add(new GuiButton(10, x + 80, y + 120, 20, 20, "++"));
          this.buttonList.add(new GuiButton(11, x - 80, y + 120, 20, 20, "-"));
          this.buttonList.add(new GuiButton(12, x - 100, y + 120, 20, 20, "--"));
          //Selecteur de son
          this.soundChooser = new GuiTextField(this.fontRenderer, 8, 170, 170, 20);//Coordonnées de 'texte'
          this.soundChooser.setMaxStringLength(100);
          this.soundChooser.setFocused(true);
          this.soundChooser.setCanLoseFocus(false);
          this.buttonList.add(new GuiButton(13, x + 80, y + 160, 20, 20, "Ok"));
          this.buttonList.add(new GuiButton(14, x + 40, y + 200, 100, 20, "Test"));
          //Initialisation des variables selon le tileEntity
          this.volume = (int)this.soundBlock.getVolume() * 100;
          this.range = this.soundBlock.getRange();
          this.delay = this.soundBlock.getDelay();
          this.sound = this.soundBlock.getSound();
          this.soundChooser.setText(this.soundBlock.getSound().replace("wsmod:",""));
          }
          @Override
          protected void actionPerformed(GuiButton guiButton){
          String sound = "wsmod:" + this.soundChooser.getText();
          switch(guiButton.id){
          case 1:
          if(this.volume < 100){
          this.volume++;
          }
          break;
          case 2:
          if(this.volume + 10 < 100){
          this.volume += 10;
          }
          else{
          this.volume = 100;
          }
          break;
          case 3:
          if(this.volume > 0){
          this.volume--;
          }
          break;
          case 4:
          if(this.volume - 10 > 0){
          this.volume -= 10;
          }
          else{
          this.volume = 0;
          }
          break;
          case 5:
          if(this.range < 100){
          this.range++;
          }
          break;
          case 6:
          if(this.range + 10 < 100){
          this.range += 10;
          }
          else{
          this.range = 100;
          }
          break;
          case 7:
          if(this.range > 0){
          this.range--;
          }
          break;
          case 8:
          if(this.range - 10 > 0){
          this.range -= 10;
          }
          else{
          this.range = 0;
          }
          break;
          case 9:
          if(this.delay < 100){
          this.delay++;
          }
          break;
          case 10:
          if(this.delay + 10 < 100){
          this.delay += 10;
          }
          else{
          this.delay = 100;
          }
          break;
          case 11:
          if(this.delay > 0){
          this.delay--;
          }
          break;
          case 12:
          if(this.delay - 10 > 0){
          this.delay -= 10;
          }
          else{
          this.delay = 0;
          }
          break;
          case 13:
          if(this.soundList.contains(sound)){
          this.sound = "" + sound;
          }
          else{
          this.soundChooser.setText(this.sound.replace("wsmod:",""));
          }
          break;
          case 14:
          this.soundBlock.worldObj.playSoundEffect(this.soundBlock.xCoord,this.soundBlock.yCoord,this.soundBlock.zCoord,this.sound,(float)this.volume/100,1.0F);
          break;
          }
          for(int i = 1; i<=5; i++){
          ByteArrayOutputStream bos = null;
          DataOutputStream dos = null;
          try{
          bos = new ByteArrayOutputStream();
          dos = new DataOutputStream(bos);
          dos.writeInt(this.soundBlock.xCoord);
          dos.writeInt(this.soundBlock.yCoord);
          dos.writeInt(this.soundBlock.zCoord);
          PacketHandler.writeString(dos,this.sound);
          dos.writeFloat((float)this.volume/100);
          dos.writeInt(this.delay);
          dos.writeInt(this.range);
          this.mc.getNetHandler().addToSendQueue(new Packet250CustomPayload("wsmod|soundBlock",bos.toByteArray()));
          break;
          }catch(Exception e){
          this.logger.warning("Erreur lors de l'envoi du packet de données du SoundBlock (essai " + i + "/5)");
          }
          }
          }
          /**
          * Called from the main game loop to update the screen.
          */
          @Override
          public void updateScreen(){
          if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead){
          this.mc.thePlayer.closeScreen();
          }
          this.soundChooser.updateCursorCounter();
          }
          @Override
          public void keyTyped(char par1, int par2){
          super.keyTyped(par1,par2);
          this.soundChooser.textboxKeyTyped(par1,par2);
          }
          @Override
          public void mouseClicked(int i, int j, int k){
          super.mouseClicked(i, j, k);
          this.soundChooser.mouseClicked(i,j,k);
          }
          @Override
          protected void drawGuiContainerForegroundLayer(int par1, int par2){
          LanguageRegistry r = LanguageRegistry.instance();
          this.fontRenderer.drawString(r.getStringLocalization("container.soundblock"),8,7,0);
          this.drawCenteredString("Volume",125,30,0,false);
          this.drawCenteredString(this.volume + "%",125,45,0,false);
          this.drawCenteredString(r.getStringLocalization("container.soundblock.range"),125,70,0,false);
          this.drawCenteredString(this.range + " blocks",125,85,0,false);
          this.drawCenteredString(r.getStringLocalization("container.soundblock.delay"),125,110,0,false);
          this.drawCenteredString(this.delay + " ticks",125,125,0,false);
          this.drawCenteredString(r.getStringLocalization("container.soundblock.sound"),125,150,0,false);
          this.soundChooser.drawTextBox();
          this.drawCenteredString(r.getStringLocalization("container.soundblock.sounds"),320,0,-6250336,true);
          int j = 0;
          for(String i : this.soundList){
          this.drawCenteredString("- " + i.replace("wsmod:",""),320,10 + j,-6250336,true);
          j += 10;
          }
          }
          @Override
          protected void drawGuiContainerBackgroundLayer(float f, int i, int j){
          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
          this.mc.getTextureManager().bindTexture(texture);
          int x = (this.width - this.xSize) / 2;
          int y = (this.height - this.ySize) / 2;
          this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
          }
          private void drawCenteredString(String par2Str, int par3, int par4, int par5, boolean shadow){
          if(shadow){
          this.fontRenderer.drawStringWithShadow(par2Str, par3 - this.fontRenderer.getStringWidth(par2Str) / 2, par4, par5);
          }
          else{
          this.fontRenderer.drawString(par2Str, par3 - this.fontRenderer.getStringWidth(par2Str) / 2, par4, par5);
          }
          }
          }

          Merci d’avance :)</string></string>

          Travaille sur un super serveur, Wirestone.

          1 réponse Dernière réponse Répondre Citer 0
          • robin4002
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 26 janv. 2014, 17:19

            Dans ton tile entity, ajoute ces deux fonctions :

            public Packet getDescriptionPacket()
            {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            this.writeToNBT(nbttagcompound);
            return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound);
            }
            public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
            {
            this.readFromNBT(pkt.data);
            }
            1 réponse Dernière réponse Répondre Citer 0
            • EclipseOnFire
              EclipseOnFire dernière édition par 1 févr. 2014, 15:14

              @‘robin4002’:

              Dans ton tile entity, ajoute ces deux fonctions :

              Elles y sont déjà, c’est ça le problème !
              Je remet mes classes modifiées… [EDIT : Supprimé pour plus de clarté]
              Peut être ai-je oublié d’ajouter quelque chose dans le GameRegistry ?

              Travaille sur un super serveur, Wirestone.

              1 réponse Dernière réponse Répondre Citer 0
              • robin4002
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 1 févr. 2014, 17:28

                Ton readFromNBT et ton writeToNBT sont inversés.

                1 réponse Dernière réponse Répondre Citer 0
                • EclipseOnFire
                  EclipseOnFire dernière édition par 1 févr. 2014, 21:22

                  @‘robin4002’:

                  Ton readFromNBT et ton writeToNBT sont inversés.

                  Mince ! Le pire c’est que j’ai dû relire le code 10 fois sans le voir O_o. Ça marche parfaitement ! Merci beaucoup de ton aide, et de celle de Superloup10.

                  Comment vous remercier ? ^^

                  Travaille sur un super serveur, Wirestone.

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

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB