Fonction des bouton du menu Ingame "GUI"
-
Sinon utilises la technique “ouvrir un gui custom à la place du gui de minecraft” en utilisant GuiOpenEvent
-
RRR’ha comment je suis censer faire sa ???
-
Non, je pence que le problème viens de la variable i (et aussi D et Q qui pourrais être remplacés par i) : il ne faut pas que se soit une variable “fixe” : il fait que se soit quelque chose comme this.height / 4 - 24 (il faut faire des tests en modifient le 24 en un autre chiffre), pour qu’elle s’adapte à la taille de l’écran.
(petite recherche toute simple dans le code du menu de minecraft) -
Ok je test
-
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. ``` -
Tu as oublié de mettre la balise Résolu.
-
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
-
Le code actuel ?
-
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”) -
Ou alors il faut juste mettre sa workspace en UTF8.
Ou passer par les fichiers de lang. -
xDDDDDD , nan donne ton code car moi sa fait pas sa

EDIT: JE VEUX DE BONHOMES AUSSIIIIIIIIIIIIIIIIIIIIIIIIIII
-
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 -
Qu’est-ce qui t’en empêche ?
-
Je ne sais pas le faire.
-
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ù ?