Changer le nom du joueur. (Change displayername)
-
Bonsoir,
Je voudrais faire un gui qui s’ouvre avant de se connexion en solo et dans ce gui faire un système de nom et prénom espacer par un “_” tiré du bas par exemple: florian_gabet (jusqu’à la c’est simple) .
J’ai fais quelques recherche pour savoir comment changer le pseudo d’un joueur et j’ai vus que il exister un event “[size=x-smallPlayerEvent.NameFormat” du coup j’ai essayer mais j’ai une érreur il semble que en 1.8 il existe plus ou il a changer de nom mais j’ai pas réussis a le trouver.]
[font=Verdana, Arial, Helvetica, sans-serifDu coup si vous connaissez le nom de l’event en 1.8 ou une autre manière de procédé n’hésitez pas :)]
[size=x-smallMerci d’avance :D]
-
Salut,
Il existe toujours.
Vérifies que tu as importé net.minecraftforge.event.entity.player.PlayerEvent et non net.minecraftforge.fml.common.gameevent.PlayerEvent -
@‘robin4002’:
Salut,
Il existe toujours.
Vérifies que tu as importé net.minecraftforge.event.entity.player.PlayerEvent et non net.minecraftforge.fml.common.gameevent.PlayerEventAh yep merci.
Par contre je viens de pensé a un truc, faudrait que je stocke les “nouveaux” nom car sinon tout les joueurs pourrons s’appeler pareil…
Comment je peux faire ?
-
Dans les tag du joueur : ExtProp
-
@‘Plaigon’:
Dans les tag du joueur : ExtProp
Ok je vais essayer de faire ça ! il existe un tuto sur le forum ?
Et j’ai une question j’essaye de ouvrir le gui selectworld après avoir valider mon nom et prénom mais c’est plutôt bugger:
if(!text.getText().equals("") && text.getText().length() > 3 && !text2.getText().equals("") && text2.getText().length() > 3) { name = text2.getText() + "_" + text.getText(); erreur = false; mc.displayGuiScreen(new GuiSelectWorld(this)); }
[20:44:52] [Client thread/INFO] [STDOUT]: [com.CSC.net.proxy.ClientProxy:onGuiOpen:184]: net.minecraft.client.gui.GuiSelectWorld@d0020a [20:44:52] [Client thread/INFO] [STDOUT]: [com.CSC.net.proxy.ClientProxy:onGuiOpen:184]: com.CSC.net.GUI.NameMenuPrincipale@11acb3a
Merci
-
https://www.minecraftforgefrance.fr/showthread.php?tid=905 ou https://www.minecraftforgefrance.fr/showthread.php?tid=3028
Quel est ton problème?
EDIT: Si ce code est dans l’event, je crois que GuiSelectWorld attends une instance de GuiMainMenu, mais tu lui fournis ton proxy.
-
@‘DiabolicaTrix’:
https://www.minecraftforgefrance.fr/showthread.php?tid=905 ou https://www.minecraftforgefrance.fr/showthread.php?tid=3028
Quel est ton problème?
EDIT: Si ce code est dans l’event, je crois que GuiSelectWorld attends une instance de GuiMainMenu, mais tu lui fournis ton proxy.
Merci pour les tutos, mon problème c’est que quand je valide mon nom et prénom je voudrai ouvrir le gui selectworld sauf que en fait ça re ouvre mon gui je sais pas si tu vois dans les logs le jeu ouvre le guiselectoworld et desuite après mon gui donc en gros le guiselectworld s’ouvre pas.
-
if (Minecraft.getMinecraft().getSession().getUsername().equals("PseudoHere")) { //code }
https://www.minecraftforgefrance.fr/showthread.php?tid=722
Edit: je sais pas si ça t’aidera en fait, sorry
-
@‘Ama’:
if (Minecraft.getMinecraft().getSession().getUsername().equals("PseudoHere")) { //code }
https://www.minecraftforgefrance.fr/showthread.php?tid=722
Edit: je sais pas si ça t’aidera en fait, sorry
Nope ça m’aide pas et ça marche pas perso.
J’ai essayer de close le gui et d’ouvrir après le gui selectworld j’ai eu un crash:
[16:31:33] [main/INFO] [GradleStart]: username: floriangabet [16:31:33] [main/INFO] [GradleStart]: Extra: [] [16:31:33] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/Admin/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --accessToken, {REDACTED}, --version, 1.8, --username, floriangabet, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [16:31:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [16:31:33] [main/INFO] [FML]: Forge Mod Loader version 8.0.37.1334 for Minecraft 1.8 loading [16:31:33] [main/INFO] [FML]: Java is Java HotSpot(TM) Client VM, version 1.8.0_45, running on Windows 7:x86:6.1, installed at C:\Program Files (x86)\Java\jdk1.8.0_45\jre [16:31:33] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [16:31:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [16:31:33] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [16:31:33] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [16:31:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [16:31:33] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [16:31:33] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [16:31:34] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [16:31:34] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [16:31:34] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [16:31:34] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [16:31:34] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [16:31:34] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [16:31:34] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [16:31:35] [Client thread/INFO]: Setting user: floriangabet [16:31:36] [Client thread/INFO]: LWJGL Version: 2.9.1 [16:31:36] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [16:31:36] [Client thread/INFO] [FML]: MinecraftForge v11.14.1.1334 Initialized [16:31:36] [Client thread/INFO] [FML]: Replaced 204 ore recipies [16:31:36] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [16:31:36] [Client thread/INFO] [FML]: Searching C:\Users\Admin\Desktop\CSC\eclipse\mods for mods [16:31:37] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [16:31:37] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, csc] at CLIENT [16:31:37] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, csc] at SERVER [16:31:37] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Cite Sous Controle [16:31:37] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [16:31:37] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations [16:31:37] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [16:31:37] [Client thread/INFO] [STDOUT]: [com.CSC.net.block.CSCBlocks:registerItemsBlocksModels:38]: registerItemsBlocksModels [16:31:37] [Client thread/INFO] [FML]: Applying holder lookups [16:31:37] [Client thread/INFO] [FML]: Holder lookups applied [16:31:37] [Sound Library Loader/INFO]: Starting up SoundSystem… [16:31:37] [Thread-7/INFO]: Initializing LWJGL OpenAL [16:31:37] [Thread-7/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [16:31:37] [Thread-7/INFO]: OpenAL initialized. [16:31:38] [Sound Library Loader/INFO]: Sound engine started [16:31:39] [Client thread/INFO]: Created: 2048x1024 textures-atlas [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_batonP#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_panierlinge#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_lesive#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_coli#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_balai#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_propre_sec#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:block_sale#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_linge_propre_mouiller#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:block_blockcuve#normal not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:block_blockcuve#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_medic#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_linge_sale#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_belier#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_clefm#inventory not found [16:31:39] [Client thread/ERROR] [FML]: Model definition for location csc:item_lingette#inventory not found [16:31:39] [Client thread/INFO] [STDOUT]: [com.CSC.net.Main:init:71]: [16:31:39] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [16:31:39] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Cite Sous Controle [16:31:39] [Client thread/INFO]: SoundSystem shutting down… [16:31:39] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com [16:31:39] [Sound Library Loader/INFO]: Starting up SoundSystem… [16:31:40] [Thread-9/INFO]: Initializing LWJGL OpenAL [16:31:40] [Thread-9/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [16:31:40] [Thread-9/INFO]: OpenAL initialized. [16:31:40] [Sound Library Loader/INFO]: Sound engine started [16:31:41] [Client thread/INFO]: Created: 2048x1024 textures-atlas [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_batonP#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_panierlinge#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_lesive#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_coli#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_balai#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_propre_sec#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:block_sale#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_linge_propre_mouiller#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:block_blockcuve#normal not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:block_blockcuve#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_medic#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_linge_sale#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_belier#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_clefm#inventory not found [16:31:41] [Client thread/ERROR] [FML]: Model definition for location csc:item_lingette#inventory not found [16:31:41] [Client thread/INFO] [STDOUT]: [com.CSC.net.proxy.ClientProxy:onGuiOpen:184]: net.minecraft.client.gui.GuiMainMenu@dbf042 [16:31:43] [Client thread/INFO] [STDOUT]: [com.CSC.net.proxy.ClientProxy:onGuiOpen:184]: net.minecraft.client.gui.GuiSelectWorld@119f982 [16:31:43] [Client thread/INFO] [STDOUT]: [com.CSC.net.proxy.ClientProxy:onGuiOpen:184]: com.CSC.net.GUI.NameMenuPrincipale@d74b13 [16:31:49] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Updating screen events at net.minecraft.client.Minecraft.runTick(Minecraft.java:1766) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45] 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.NullPointerException at com.CSC.net.GUI.NameMenuPrincipale.actionPerformed(NameMenuPrincipale.java:85) ~[NameMenuPrincipale.class:?] at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510) ~[GuiScreen.class:?] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:602) ~[GuiScreen.class:?] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:571) ~[GuiScreen.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1752) ~[Minecraft.class:?] … 11 more [16:31:49] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: –-- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 10/10/16 16:31 Description: Updating screen events java.lang.NullPointerException: Updating screen events at com.CSC.net.GUI.NameMenuPrincipale.actionPerformed(NameMenuPrincipale.java:85) at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:602) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:571) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1752) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.CSC.net.GUI.NameMenuPrincipale.actionPerformed(NameMenuPrincipale.java:85) at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:510) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:602) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:571) -- Affected screen -- Details: Screen name: com.CSC.net.GUI.NameMenuPrincipale Stacktrace: at net.minecraft.client.Minecraft.runTick(Minecraft.java:1752) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 7 (x86) version 6.1 Java Version: 1.8.0_45, Oracle Corporation Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation Memory: 695670536 bytes (663 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.10 FML v8.0.37.1334 Minecraft Forge 11.14.1.1334 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available csc{1.0} [Cite Sous Controle] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available Loaded coremods (and transformers): Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 368.39, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: Français (France) Profiler Position: N/A (disabled) [16:31:49] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Admin\Desktop\CSC\eclipse\.\crash-reports\crash-2016-10-10_16.31.49-client.txt AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
La ligne 85 de NameMenuPrincipal est:
@Override protected void actionPerformed(GuiButton button) throws IOException { switch(button.id) { case 0: if(!text.getText().equals("") && text.getText().length() > 3 && !text2.getText().equals("") && text2.getText().length() > 3) { name = text2.getText() + "_" + text.getText(); erreur = false; mc.thePlayer.closeScreen();// celle ci mc.displayGuiScreen(new GuiSelectWorld(this)); } else { erreur = true; } break; default: break; } super.actionPerformed(button); }
Merci quand même
-
Retire ça : mc.thePlayer.closeScreen(); car comme aucun monde n’est chargé, mc.thePlayer est null, sinon je pense que quand tu appeles l’ouverture du GuiSelectWorld, l’event que t’a utilisé pour afficher ton gui custom est re-appelé, et donc le gui custom re-affiché, tu pourrais faire un boolean mise à true quand tu ouvres le GuiSelectWorld qui bloquera l’ouverture de ton gui custom.
-
@‘AymericRed’:
Retire ça : mc.thePlayer.closeScreen(); car comme aucun monde n’est chargé, mc.thePlayer est null, sinon je pense que quand tu appeles l’ouverture du GuiSelectWorld, l’event que t’a utilisé pour afficher ton gui custom est re-appelé, et donc le gui custom re-affiché, tu pourrais faire un boolean mise à true quand tu ouvres le GuiSelectWorld qui bloquera l’ouverture de ton gui custom.
Ah mais oui exact je suis bête !
Merci aymeric
J’ai une question:
est-ce que c’est normal que mes deux GuiTextField soit “relié” quand j’écris dans l’un florian par exemple dans l’autre automatiquement ça va écrire pareil ^^
Je vous passe mon code:
package com.CSC.net.GUI; import java.io.IOException; import java.util.Date; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiSelectWorld; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import com.CSC.net.Main; import com.CSC.net.item.batonP; public class NameMenuPrincipale extends GuiScreen{ public static String name; private static boolean erreur; public static boolean b; private ResourceLocation ressource = new ResourceLocation(Main.MODID + ":textures/gui/PrisonGui.png"); private int valider; private int nom; private int prenom; public static GuiTextField text; public static GuiTextField text2; public NameMenuPrincipale() { } @Override public void initGui() { valider = 0; nom = 1; prenom = 2; text = new GuiTextField(nom, fontRendererObj, width / 2 - 32, 130, 64, 20); text2 = new GuiTextField(prenom, fontRendererObj, width / 2, 100, 64, 20); text.setFocused(true); text2.setFocused(true); Keyboard.enableRepeatEvents(true); this.buttonList.add(new GuiButton(valider, width / 2 - 123, 230, 40, 20, "Valider")); super.initGui(); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { text.textboxKeyTyped(typedChar, keyCode); super.keyTyped(typedChar, keyCode); text2.textboxKeyTyped(typedChar, keyCode); } @Override protected void actionPerformed(GuiButton button) throws IOException { switch(button.id) { case 0: if(!text.getText().equals("") && text.getText().length() > 3 && !text2.getText().equals("") && text2.getText().length() > 3) { System.out.println(b); System.out.println(name); b = false; name = text2.getText() + "_" + text.getText(); erreur = false; mc.displayGuiScreen(new GuiSelectWorld(this)); } else { erreur = true; } break; default: erreur = false; break; } super.actionPerformed(button); } @Override public void updateScreen() { super.updateScreen(); } public void drawScreen(int mouseX, int mouseY, float partialTick) { mc.getTextureManager().bindTexture(ressource); text.drawTextBox(); text2.drawTextBox(); this.drawTexturedModalRect(this.width / 2 - 135, this.height / 2 - 125, 0, 0, 256, 250); super.drawScreen(mouseX, mouseY, partialTick); if(erreur) { this.drawString(fontRendererObj, "§cVotre nom et/ou prénom est/sont vide ou trop court !", this.width / 2, this.height / 2 - 125, 0); } } @Override public void onGuiClosed() { } private static Date setDate(int delay) { Date date = new Date(); date.setSeconds(date.getSeconds() + delay); return date; } }
EDIT:
Et aussi j’avais oublier ça c’est normal ?:
-
text.textboxKeyTyped(typedChar, keyCode); super.keyTyped(typedChar, keyCode); text2.textboxKeyTyped(typedChar, keyCode);
Dès qu’une touche est tappée, les fonctions de tes deux text fields sont appelées en même temps, et on donc le même contenu.
mc.getTextureManager().bindTexture(ressource); text.drawTextBox(); text2.drawTextBox(); this.drawTexturedModalRect(this.width / 2 - 135, this.height / 2 - 125, 0, 0, 256, 250);
1. Tu bind la texture de fond d’écran.
2. et 3. tu dessines tes text fields.
4. Tu dessines le fond d’écran, à ce moment la texture qui est bind est celle de toutes les lettres. -
@‘AymericRed’:
text.textboxKeyTyped(typedChar, keyCode); super.keyTyped(typedChar, keyCode); text2.textboxKeyTyped(typedChar, keyCode);
Dès qu’une touche est tappée, les fonctions de tes deux text fields sont appelées en même temps, et on donc le même contenu.
mc.getTextureManager().bindTexture(ressource); text.drawTextBox(); text2.drawTextBox(); this.drawTexturedModalRect(this.width / 2 - 135, this.height / 2 - 125, 0, 0, 256, 250);
1. Tu bind la texture de fond d’écran.
2. et 3. tu dessines tes text fields.
4. Tu dessines le fond d’écran, à ce moment la texture qui est bind est celle de toutes les lettres.Ah ouaip d’acc,
par contre pour le keytyped comment je peux faire car je peux pas crée une secondes fonction.
EDIT:
Et aussi je me suis toujours demandé:
Comment on fait pour dédessiner sur toute la largeur/longueur de l’écran de jeu ?
Car moi ça rend comme ça c’est pas jolie:
http://puu.sh/rFc0V/83f14cc212.PNGMerci
-
Au final laissez tomber j’ai changer d’idée je vais pas faire un screen mais je vais faire une commande.
Donc j’ai fais ça:
package com.CSC.net.Commands; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; public class NameCommand extends CommandBase{ public static String name = null; @Override public String getName() { return "name"; } @Override public String getCommandUsage(ICommandSender sender) { return null; } @Override public void execute(ICommandSender sender, String[] args) throws CommandException { if(sender instanceof EntityPlayer) { if(args.length == 2) { name = args[0] + "_" + args[1]; sender.addChatMessage(new ChatComponentText("Votre identité à bien était changer")); } else if(args.length == 1) { name = args[0]; sender.addChatMessage(new ChatComponentText("Votre identité à bien était changer")); } else { sender.addChatMessage(new ChatComponentText("Usage: /name <prénom><nom>| /name <prénom ou="" nom="">")); } } } }
Event:
@SubscribeEvent public void test(PlayerEvent.NameFormat e) { e.displayname = NameCommand.name; System.out.println(e.displayname); }
Je voudrais que le joueur puisse changer de nom dès que il le souhaite mais le problème et que une fois que le nom est attribué (en faisant la commande une fois )je ne peux plus changer de nom l’event est plus appeler …
Et j’ai une question:
Faudrait pas stocker le nom des joueurs ?
Si je les stockes pas je risques quoi ?</prénom></nom></prénom>