MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Fonction des bouton du menu Ingame "GUI"

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.7.10
    40 Messages 7 Publieurs 7.7k Vues 1 Abonné
    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.
    • T Hors-ligne
      titoux99
      dernière édition par

      Bon voilà mon problème est résolu sa marche parfaitement maintenant !! Merci en tous cas.

      Je vais expliquez se qui ne marché pas pour les autres en même difficulté que moi.
      Je vous met directement le code comme ça vous pourrez vous aidez.

      public class TestGui extends GuiScreen
      {
         private int field_146445_a;
         private int field_146444_f;
         private static final String __OBFID = "CL_00000703";
      
      // Gui
         @SubscribeEvent
         public void onInitGuiIngameEvent(InitGuiEvent.Post event)
         {
             if(event.gui instanceof GuiIngameMenu)
             {
                 // on cache les boutons de base
                 for(Object b : event.buttonList)
                 {
                     int buttonId = ((GuiButton)b).id;
                     if(buttonId == 1 || buttonId == 4 || buttonId == 0 || buttonId == 2 || buttonId == 7 || buttonId == 5 || buttonId == 12 || buttonId == 6)
                     {
                         ((GuiButton)b).visible = false;
                     }
                 }
                 int i = 16;
                 event.buttonList.add(new GuiButton(-1, event.gui.width / 2 + 2, this.height / 4 + 120 + i, 98, 20, "§6Votez"){});
                 event.buttonList.add(new GuiButton(5, event.gui.width / 2 - 100, this.height / 4 + 72 + i, 98, 20, "§5Succes"){});
                 event.buttonList.add(new GuiButton(6, event.gui.width / 2 - 100, this.height / 4 + 120 + i, 98, 20, "§bStatistiques"){});
                 event.buttonList.add(new GuiButton(0, event.gui.width / 2 - 100, this.height / 4 + 96 + i, 98, 20, I18n.format("§7Options", new Object[0])));
                 event.buttonList.add(new GuiButton(80, event.gui.width / 2 + 2, this.height / 4 + 72 + i, 98, 20, "§3Site")
                     {
                         @Override
                         public void mouseReleased(int x, int y) 
                             {
                                 if (Desktop.isDesktopSupported())
                             {
                             try
                             {
                                 Desktop.getDesktop().browse(new URI("https://ww****.fr));
                             }
                             catch(IOException e)
                             {
                                 e.printStackTrace();
                             }
                             catch(URISyntaxException e)
                             {
                                 e.printStackTrace();
                             }
      }}});
                 event.buttonList.add(new GuiButton(81, event.gui.width / 2 + 2, this.height / 4 + 96 + i, 98, 20, "§2TeamSpeak")
                         {
                     @Override
                     public void mouseReleased(int x, int y) 
                     {
                         if (Desktop.isDesktopSupported())
                         {
                             try
                             {
                                 Desktop.getDesktop().browse(new URI("ts3server://90****"));
                             }
                             catch(IOException e)
                             {
                                 e.printStackTrace();
                             }
                             catch(URISyntaxException e)
                             {
                                 e.printStackTrace();
                             }
      }}});
                 event.buttonList.add(new GuiButton(4, event.gui.width / 2 - 100, this.height / 4 + 48 + i, "§e§lRetour au Jeu"){});
                 event.buttonList.add(new GuiButton(1, event.gui.width / 2 - 100, this.height / 4 + 144 + i, "§c§lDeconnexion"){});
         }
         }
      
         protected void actionPerformed(GuiButton p_146284_1_)
         {
             switch (p_146284_1_.id)
             {
                 case 0:
                     this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
                     break;
                 case 1:
                     p_146284_1_.enabled = false;
                     this.mc.theWorld.sendQuittingDisconnectingPacket();
                     this.mc.loadWorld((WorldClient)null);
                     this.mc.displayGuiScreen(new GuiMainMenu());
                 case 2:
                 case 3:
                 default:
                     break;
                 case 4:
                     this.mc.displayGuiScreen((GuiScreen)null);
                     this.mc.setIngameFocus();
                     break;
                 case 5:
                     if (this.mc.thePlayer != null)
                     this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
                     break;
                 case 6:
                     if (this.mc.thePlayer != null)
                     this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
                     break;
                 case 7:
                     this.mc.displayGuiScreen(new GuiShareToLan(this));
                     break;
             }
         }
      
         public void updateScreen()
         {
             super.updateScreen();
             ++this.field_146444_f;
         }
      
         /**
          * Draws the screen and all the components in it.
          */
         public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
         {
             this.drawDefaultBackground();
             this.drawCenteredString(this.fontRendererObj, I18n.format("menu.game", new Object[0]), this.width / 2, 40, 16777215);
             super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
         }  
      }
      
      

      Pour le problème j’ai juste du remplacer ça:

      event.buttonList.add(new GuiButton(-1, event.gui.width / 2 + 2, i + 8 * 31, 98, 20, "§6Votez")
      

      Par ça:

      event.buttonList.add(new GuiButton(-1, event.gui.width / 2 + 2, this.height / 4 + 120 + i, 98, 20, "§6Votez"){});
      

      Et ajouter ça dans la class:

      
      1.  **protected** **void** actionPerformed(GuiButton p_146284_1_)
      2.     {
      3.         **switch** (p_146284_1_.id)
      4.         {
      5.             **case** 0:
      6.                 **this**.mc.displayGuiScreen(**new** GuiOptions(**this**, **this**.mc.gameSettings));
      7.                 **break**;
      8.             **case** 1:
      9.                 p_146284_1_.enabled = **false**;
      10.                 **this**.mc.theWorld.sendQuittingDisconnectingPacket();
      11.                 **this**.mc.loadWorld((WorldClient)**null**);
      12.                 **this**.mc.displayGuiScreen(**new** GuiMainMenu());
      13.             **case** 2:
      14.             **case** 3:
      15.             **default**:
      16.                 **break**;
      17.             **case** 4:
      18.                 **this**.mc.displayGuiScreen((GuiScreen)**null**);
      19.                 **this**.mc.setIngameFocus();
      20.                 **break**;
      21.             **case** 5:
      22.                 **if** (**this**.mc.thePlayer != **null**)
      23.                 **this**.mc.displayGuiScreen(**new** GuiAchievements(**this**, **this**.mc.thePlayer.getStatFileWriter()));
      24.                 **break**;
      25.             **case** 6:
      26.                 **if** (**this**.mc.thePlayer != **null**)
      27.                 **this**.mc.displayGuiScreen(**new** GuiStats(**this**, **this**.mc.thePlayer.getStatFileWriter()));
      28.                 **break**;
      29.             **case** 7:
      30.                 **this**.mc.displayGuiScreen(**new** GuiShareToLan(**this**));
      31.                 **break**;
      32.         }
      33.     }
      
          ```
      34.  Qui permet de choisir les fonction qu'on veux attribuer a nos bouton
      35.  %(#666600)[Comme par exemple:
          ]
      36.  ```java
          @SubscribeEvent
              public void onInitGuiIngameEvent(InitGuiEvent.Post event)
              {
                  if(event.gui instanceof GuiIngameMenu)
                  {
                      int i = 16;
                      event.buttonList.add(new GuiButton(0 , event.gui.width / 2 + 2, this.height / 4 + 120 + i, 98, 20, "§6EXEMPLE"){});            // Ici 0 en rapport avec ceux que on veut lui attribuer quand on clique dessus. 0 en rapport avec la fonction actionPerformed plus bas en occurence   case 0   donc ouvrir le menu OPTION de minecraft
      
          1.  **protected** **void** actionPerformed(GuiButton p_146284_1_)
          2.     {
          3.         **switch** (p_146284_1_.id)
          4.         {
          5.             **case** 0:
          6.                 **this**.mc.displayGuiScreen(**new** GuiOptions(**this**, **this**.mc.gameSettings));
          7.                 **break**;
      37.  ```
      1 réponse Dernière réponse Répondre Citer 0
      • AymericRedA Hors-ligne
        AymericRed
        dernière édition par

        Tu as oublié de mettre la balise Résolu.

        Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

        AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

        Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
        Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

        1 réponse Dernière réponse Répondre Citer 0
        • T Hors-ligne
          titoux99
          dernière édition par

          Par contre je comprend pas, quand je le lance sur mon launcher ça met des tête devant les mots :c http://prntscr.com/bkftb9

          1 réponse Dernière réponse Répondre Citer 0
          • moscaphone421M Hors-ligne
            moscaphone421
            dernière édition par

            Le code actuel ?

            1 réponse Dernière réponse Répondre Citer 0
            • LeBossMax2L Hors-ligne
              LeBossMax2
              dernière édition par

              Le problème est au niveau du nom des bouton, il faut utiliser autre chose que “§6”, il y a une class faite exprès pour ça mais je ne sais plus comment elle s’appelle.

              Edit : j’ai trouvé, c’est EnumChatFormatting
              (ex : EnumChatFormatting.GOLD + “Votez” au lieux de “§6Votez”)

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

                Ou alors il faut juste mettre sa workspace en UTF8.
                Ou passer par les fichiers de lang.

                1 réponse Dernière réponse Répondre Citer 0
                • ? Hors-ligne
                  Un Ancien Utilisateur
                  dernière édition par

                  xDDDDDD , nan donne ton code car moi sa fait pas sa 😕

                  EDIT: JE VEUX DE BONHOMES AUSSIIIIIIIIIIIIIIIIIIIIIIIIIII

                  1 réponse Dernière réponse Répondre Citer 0
                  • T Hors-ligne
                    titoux99
                    dernière édition par

                    Mon code pour les gens a qui sa marche pas.

                    
                    @SubscribeEvent
                       public void onInitGuiIngameEvent(InitGuiEvent.Post event)
                       {
                           if(event.gui instanceof GuiIngameMenu)
                           {
                               // on cache les boutons de base
                               for(Object b : event.buttonList)
                               {
                                   int buttonId = ((GuiButton)b).id;
                                   if(buttonId == 1 || buttonId == 4 || buttonId == 0 || buttonId == 2 || buttonId == 7 || buttonId == 5 || buttonId == 12 || buttonId == 6)
                                   {
                                       ((GuiButton)b).visible = false;
                                   }
                               }
                               int i = 16;
                               event.buttonList.add(new GuiButton(-1, event.gui.width / 2 + 2, this.height / 4 + 120 + i, 98, 20, EnumChatFormatting.GOLD + "Votez"){});
                               event.buttonList.add(new GuiButton(5, event.gui.width / 2 - 100, this.height / 4 + 72 + i, 98, 20, EnumChatFormatting.DARK_PURPLE + "Succes"){});
                               event.buttonList.add(new GuiButton(6, event.gui.width / 2 - 100, this.height / 4 + 120 + i, 98, 20, EnumChatFormatting.BLUE + "Statistiques"){});
                               event.buttonList.add(new GuiButton(0, event.gui.width / 2 - 100, this.height / 4 + 96 + i, 98, 20, EnumChatFormatting.GRAY + "Options"));
                               event.buttonList.add(new GuiButton(80, event.gui.width / 2 + 2, this.height / 4 + 72 + i, 98, 20, EnumChatFormatting.DARK_BLUE + "Site")
                                   {
                                       @Override
                                       public void mouseReleased(int x, int y)
                                           {
                                               if (Desktop.isDesktopSupported())
                                           {
                                           try
                                           {
                                               Desktop.getDesktop().browse(new URI("https://w****x.fr/"));
                                           }
                                           catch(IOException e)
                                           {
                                               e.printStackTrace();
                                           }
                                           catch(URISyntaxException e)
                                           {
                                               e.printStackTrace();
                                           }
                    }}});
                               event.buttonList.add(new GuiButton(81, event.gui.width / 2 + 2, this.height / 4 + 96 + i, 98, 20, EnumChatFormatting.DARK_GREEN + "TeamSpeak")
                                       {
                                   @Override
                                   public void mouseReleased(int x, int y)
                                   {
                                       if (Desktop.isDesktopSupported())
                                       {
                                           try
                                           {
                                               Desktop.getDesktop().browse(new URI("ts3server://90.****7"));
                                           }
                                           catch(IOException e)
                                           {
                                               e.printStackTrace();
                                           }
                                           catch(URISyntaxException e)
                                           {
                                               e.printStackTrace();
                                           }
                    }}});
                               event.buttonList.add(new GuiButton(4, event.gui.width / 2 - 100, this.height / 4 + 48 + i, EnumChatFormatting.YELLOW + "Retour au Jeu"){});
                               event.buttonList.add(new GuiButton(1, event.gui.width / 2 - 100, this.height / 4 + 144 + i, EnumChatFormatting.RED + "Deconnexion"){});
                       }
                    }
                    
                       protected void actionPerformed(GuiButton p_146284_1_)
                       {
                           switch (p_146284_1_.id)
                           {
                               case 0:
                                   this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
                                   break;
                               case 1:
                                   p_146284_1_.enabled = false;
                                   this.mc.theWorld.sendQuittingDisconnectingPacket();
                                   this.mc.loadWorld((WorldClient)null);
                                   this.mc.displayGuiScreen(new GuiMainMenu());
                               case 2:
                               case 3:
                               default:
                                   break;
                               case 4:
                                   this.mc.displayGuiScreen((GuiScreen)null);
                                   this.mc.setIngameFocus();
                                   break;
                               case 5:
                                   if (this.mc.thePlayer != null)
                                   this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter()));
                                   break;
                               case 6:
                                   if (this.mc.thePlayer != null)
                                   this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter()));
                                   break;
                               case 7:
                                   this.mc.displayGuiScreen(new GuiShareToLan(this));
                                   break;
                           }
                       }
                    
                       public void updateScreen()
                       {
                           super.updateScreen();
                           ++this.field_146444_f;
                       }
                    
                       /**
                        * Draws the screen and all the components in it.
                        */
                       public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
                       {
                           this.drawDefaultBackground();
                           this.drawCenteredString(this.fontRendererObj, I18n.format("menu.game", new Object[0]), this.width / 2, 40, 16777215);
                           super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
                       }  
                    }
                    
                    

                    Et si il y a un moyen de mettre le skin comme ça:    http://prntscr.com/blanlg
                    Et de mettre un petit message aussi:    http://prntscr.com/blao1q

                    1 réponse Dernière réponse Répondre Citer 0
                    • SCAREXS Hors-ligne
                      SCAREX
                      dernière édition par

                      Qu’est-ce qui t’en empêche ?

                      Site web contenant mes scripts : http://SCAREXgaming.github.io

                      Pas de demandes de support par MP ni par skype SVP.
                      Je n'accepte sur skype que l…

                      1 réponse Dernière réponse Répondre Citer 0
                      • T Hors-ligne
                        titoux99
                        dernière édition par

                        Je ne sais pas le faire.

                        1 réponse Dernière réponse Répondre Citer 0
                        • SCAREXS Hors-ligne
                          SCAREX
                          dernière édition par

                          Et bien fait des recherches :

                          • Pour ce qui est du skin moi j’irai voir le Gui de l’inventaire du joueur
                          • Pour ce qui est du message, je ne vois pas ce que je peux te dire : tu bloques où ?

                          Site web contenant mes scripts : http://SCAREXgaming.github.io

                          Pas de demandes de support par MP ni par skype SVP.
                          Je n'accepte sur skype que l…

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

                          MINECRAFT FORGE FRANCE © 2024

                          Powered by NodeBB