Résolu Game Menu
-
J’ai encore jamais vu ça, réinstalle Eclipse.
-
Donc voilà j’ai une erreur ici mon code du dossier ModCustomMenu : ```java
package fr.minecraftforgefrance.client.custommenu;import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.gui.GuiMainMenu;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;@Mod(modid = “custommenu”, name = “SlideFight InGame”, version = “1.0”)
public class ModCustomMenu
{
@EventHandler
public void init(FMLInitializationEvent event)
{
if(event.getSide().isClient())
{
FMLCommonHandler.instance().bus().register(this);
}
}@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTick(TickEvent.ClientTickEvent event)
{
Minecraft mc = FMLClientHandler.instance().getClient();
if(mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiIngameMenu.class))
{
mc.displayGuiScreen(new GuiCustomIngameMenu());
}
else if(mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiIngameMenu.class)){
mc.displayGuiScreen(new GuiCustomIngameMenu());
}
}
}Et le code source de GuiCustomIngameMenu : ```java package fr.minecraftforgefrance.client.custommenu; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiOptions; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiShareToLan; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.resources.I18n; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiCustomIngameMenu extends GuiScreen { private int field_146445_a; private int field_146444_f; private static final String __OBFID = "CL_00000703"; /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { this.field_146445_a = 0; this.buttonList.clear(); byte b0 = -16; boolean flag = true; this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + b0, I18n.format("menu.returnToMenu", new Object[0]))); if (!this.mc.isIntegratedServerRunning()) { ((GuiButton)this.buttonList.get(0)).displayString = I18n.format("menu.disconnect", new Object[0]); } this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + b0, I18n.format("menu.returnToGame", new Object[0]))); this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + b0, 98, 20, I18n.format("menu.options", new Object[0]))); this.buttonList.add(new GuiButton(12, this.width / 2 + 2, this.height / 4 + 96 + b0, 98, 20, "Mod Options…")); GuiButton guibutton; this.buttonList.add(guibutton = new GuiButton(7, this.width / 2 - 100, this.height / 4 + 72 + b0, 200, 20, I18n.format("menu.shareToLan", new Object[0]))); this.buttonList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + b0, 98, 20, I18n.format("gui.achievements", new Object[0]))); this.buttonList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + b0, 98, 20, I18n.format("gui.stats", new Object[0]))); guibutton.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic(); } 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; case 12: FMLClientHandler.instance().showInGameModOptions(this); break; } } /** * Called from the main game loop to update the screen. */ 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_); } }
L’erreur est marquée ici :
java FMLClientHandler.instance().showInGameModOptions(this);
exactement ici : ```java
showInGameModOptionsEnsuite comment modifier un bouton pour que quand un joueur clique dessus il arrive sur le site ? Merci d'avance
-
Ta classe principale n’est pas bon, je t’avais pourtant donné le bon code ici :
http://www.minecraftforgefrance.fr/showthread.php?tid=2055&pid=23389#pid23389Pour l’erreur avec le
FMLClientHandler.instance().showInGameModOptions(this);
retire toute la ligne, de toute façon ce menu n’est pas encore fonctionnel. -
Minecraft mc = FMLClientHandler.instance().getClient(); if(mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiIngameMenu.class)) { mc.displayGuiScreen(new GuiCustomIngameMenu()); } else if(mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiIngameMenu.class)) { mc.displayGuiScreen(new GuiCustomIngameMenu()); }
Useless or not useless ? That is the question.
Essaie avec çà plutôt :
[java
Minecraft mc = FMLClientHandler.instance().getClient();
if(mc.currentScreen instanceof GuiIngameMenu)
{
mc.displayGuiScreen(new GuiCustomIngameMenu());
}
[/java]Pour l’erreur : ta classe n’est pas extend GuiIngameMenu.
-
ça fonctionne mais voilà encore un de mes problèmes : ```java
package fr.minecraftforgefrance.client.custommenu;import java.awt.Desktop;
import java.net.URL;import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiOptions;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.gui.achievement.GuiStats;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.I18n;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;@SideOnly(Side.CLIENT)
public class GuiCustomIngameMenu extends GuiIngameMenu
{
private int field_146445_a;
private int field_146444_f;
private static final String __OBFID = “CL_00000703”;/**
- Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
this.field_146445_a = 0;
this.buttonList.clear();
byte b0 = -16;
boolean flag = true;
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + b0, I18n.format(“menu.returnToMenu”, new Object[0])));
if (!this.mc.isIntegratedServerRunning())
{
((GuiButton)this.buttonList.get(0)).displayString = I18n.format(“menu.disconnect”, new Object[0]);
}this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + b0, I18n.format(“menu.returnToGame”, new Object[0])));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + b0, 98, 20, I18n.format(“menu.options”, new Object[0])));
this.buttonList.add(new GuiButton(12, this.width / 2 + 2, this.height / 4 + 96 + b0, 98, 20, “TS3”));
GuiButton guibutton;
this.buttonList.add(guibutton = new GuiButton(7, this.width / 2 - 100, this.height / 4 + 72 + b0, 200, 20, I18n.format(“Site”, new Object[0])));
this.buttonList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + b0, 98, 20, I18n.format(“gui.achievements”, new Object[0])));
this.buttonList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + b0, 98, 20, I18n.format(“gui.stats”, new Object[0])));
guibutton.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic();
}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:Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL(“http://slidefight.fr”).toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case 12:
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL(“ts3server://151.80.115.24?port=”).toURI());
} catch (Exception e) {
e.printStackTrace();
}
} break;
}
}/**
- Called from the main game loop to update the screen.
*/
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_);
}
}
Il y a une erreur ici : ```java case 12: Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
Plus précisément ici : ```java
Desktop desktop - Adds the buttons (and other controls) to the screen in question.
-
Il faut un copier/coller du rapport de crash.
-
La variable est déjà utilisée plus haut, change juste le nom de la variable.
-
D’accord pour le bouton du site ça fonctionne et si je veux faire un bouton ts3 comment faire ? J’ai mis ce code la mais ça fonctionne pas ça ne m’ouvre pas teamspeak : ```java
case 12:
Desktop teamspeak = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (teamspeak != null && teamspeak.isSupported(Desktop.Action.BROWSE))
{
try {
teamspeak.browse(new URL(“ts3server://151.80.115.24?port=”).toURI());
} catch (Exception e) {
e.printStackTrace();
}
}
break; -
ts3server://151.80.115.24?port=9987
-
ça ne fonctionne toujours pas voilà ce que j’ai dans la console : ```
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.net.MalformedURLException: unknown protocol: ts3server
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.net.URL.<init>(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.net.URL.<init>(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.net.URL.<init>(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at fr.minecraftforgefrance.client.custommenu.GuiCustomIngameMenu.actionPerformed(GuiCustomIngameMenu.java:96)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:252)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:344)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:313)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.runTick(Minecraft.java:1720)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.run(Minecraft.java:951)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.main.Main.main(Main.java:164)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
[20:58:07] [Client thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at GradleStart.main(Unknown Source) -
Tu es sous quel système d’exploitation ?
-
Windows 8
-
Il ne faut pas faire URL.toURI(), fait directement new URI(“ts3server:…”).
-
Comment ça ? Je comprends pas ?
-
@‘Zedokf_DrM’:
Comment ça ? Je comprends pas ?
Une URL ne peut avoir comme protocole http, https, ftp, sftp ou ftps et non ts3server, il faut donc utiliser une URI, mets çà :
teamspeak.browse(new URI("ts3server://151.80.115.24?port=9987"));
à la place de :
teamspeak.browse(new URL("ts3server://151.80.115.24?port=").toURI());