GuiIngameMenu help



  • bonjour ou bonsoir j ai fais un guiingamemenu qui marche sur ecplise est aficher mais quand je compile mon mod et je le mais sur mon minecraft de base il n aparais pas mais mes item aparaisse
    voici mon code

    package net.minecraft.client.gui;

    import cpw.mods.fml.client.FMLClientHandler;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    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;

    @SideOnly(Side.CLIENT)
    public class GuiIngameMenu 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_);
        }
    }



  • Bonsoir,
    Déjà, essayes d'utiliser les balises java ça sera plus clair pour nous ^^
    Ensuite si ton gui ne s'affiche pas, le problème doit être autre part, peux-tu donner la classe où tu fais s'afficher le gui (probablement ta classe d'event, et le code que tu utilises pour la register) ?



  • @'AymericRed':

    Bonsoir,
    Déjà, essayes d'utiliser les balises java ça sera plus clair pour nous ^^
    Ensuite si ton gui ne s'affiche pas, le problème doit être autre part, peux-tu donner la classe où tu fais s'afficher le gui (probablement ta classe d'event, et le code que tu utilises pour la register) ?

    package net.minecraft.client.gui;
    
    import java.awt.Desktop;
    import java.net.URI;
    import java.util.List;
    import org.lwjgl.opengl.GL11;
    import org.lwjgl.opengl.GL12;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.Reference;
    import net.minecraft.client.gui.achievement.GuiAchievements;
    import net.minecraft.client.gui.achievement.GuiStats;
    import net.minecraft.client.multiplayer.GuiConnecting;
    import net.minecraft.client.multiplayer.WorldClient;
    import net.minecraft.client.renderer.OpenGlHelper;
    import net.minecraft.client.renderer.RenderHelper;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.client.renderer.entity.RenderManager;
    import net.minecraft.client.renderer.texture.DynamicTexture;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.util.EnumChatFormatting;
    import net.minecraft.util.ResourceLocation;
    
    @SideOnly(Side.CLIENT)
    public class GuiIngameMenu extends GuiScreen
    
    {
        private int field_146445_a;
        private int field_146444_f;
        private static final String __OBFID = "CL_00000703";
        private static final ResourceLocation head = new ResourceLocation("textures/gui/head.png");
    
        /**
         * Adds the buttons (and other controls) to the screen in question.
         */
        public void initGui()
        {
    
            this.field_146445_a = 0;
            this.buttonList.clear();
            byte var1 = -16;
            boolean var2 = true;
            this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 160 + var1, I18n.format(EnumChatFormatting.DARK_GREEN + "D�connexion", new Object[0])));
    
            if (!this.mc.isIntegratedServerRunning())
            {
                ((GuiButton)this.buttonList.get(0)).displayString = I18n.format("D�connexion", new Object[0]);
            }
    
            this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 130 + var1, I18n.format(EnumChatFormatting.GOLD + "Revenir en jeu", new Object[0])));
    
            this.buttonList.add(new GuiButton(2, this.width / 2 - 200, this.height / 4 + 66 + var1, 98, 20, I18n.format(EnumChatFormatting.BLUE + "Site", new Object[0])));
    
            this.buttonList.add( new GuiButton(3, this.width / 2 + 102, this.height / 4 + 66 + var1, 98, 20, I18n.format(EnumChatFormatting.DARK_PURPLE + "Vote", new Object[0])));
    
            //this.buttonList.add(new GuiButton(10, this.width / 2 - ((mc.getSession().getUsername().length() * 8 + 10) / 2), this.height / 4 + 50 , mc.getSession().getUsername().length() * 8 + 10, 20, I18n.format(EnumChatFormatting.UNDERLINE + mc.getSession().getUsername(), new Object[0])));
    
            this.buttonList.add(new GuiButton(0, this.width / 2 - 200, this.height / 4 + 96 + var1, 98, 20, I18n.format(EnumChatFormatting.GREEN +"Options", new Object[0])));
    
            this.buttonList.add( new GuiButton(7, this.width / 2 + 102, this.height / 4 + 96 + var1, 98, 20, I18n.format(EnumChatFormatting.YELLOW + "Teamspeak", new Object[0])));
    
            this.buttonList.add(new GuiButton(5, this.width / 2 - 180, this.height / 4 + 28 + var1, 98, 20, I18n.format(EnumChatFormatting.DARK_AQUA +"Boutique", new Object[0])));
            this.buttonList.add(new GuiButton(6, this.width / 2 + 82, this.height / 4 + 28 + var1, 98, 20, I18n.format(EnumChatFormatting.RED +"R�glement", new Object[0])));
        }
    
        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());
                    break;
                case 2:
                    try
                    {
                        URI var2 = new URI("https://thurnfight.fr");
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                    }
                    catch (Exception var7)
                    {
                        var7.printStackTrace();
                    }
                    break;
                case 3:
                    try
                    {
                        URI var2 = new URI("https://thurnfight.fr/vote");
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                    }
                    catch (Exception var7)
                    {
                        var7.printStackTrace();
                    }
                    break;
                default:
                    break;
    
                case 4:
                    this.mc.displayGuiScreen((GuiScreen)null);
                    this.mc.setIngameFocus();
                    break;
    
                case 5:
                    try
                    {
                        URI var2 = new URI("https://thurnfight.fr/shop");
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                    }
                    catch (Exception var7)
                    {
                        var7.printStackTrace();
                    }
                    break;
                case 6:
                    try
                    {
                        URI var2 = new URI("https://thurnfight.fr/p/R�glement");
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                        }
                        catch (Exception var7)
                        {
                            var7.printStackTrace();
                        }
                        break;                    
                case 7:
                    try
                    {
                        URI var2 = new URI("ts3server://ts.thurnfight.fr?nickname=" + mc.getSession().getUsername());
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                    }
                    catch (Exception var7)
                    {
                        var7.printStackTrace();
                    }
                    break;
                case 10:
                    try
                    {
                        URI var2 = new URI("https://thurnfight.fr" + mc.getSession().getUsername());
    
                        if (Desktop.isDesktopSupported())
                        {
                            Desktop.getDesktop().browse(var2);
                        }
                    }
                    catch (Exception var7)
                    {
                        var7.printStackTrace();
                    }
                    break;
            }
        }
    
        public static void func_147046_a(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_)
        {
            GL11.glEnable(GL11.GL_COLOR_MATERIAL);
            GL11.glPushMatrix();
            GL11.glTranslatef((float)p_147046_0_, (float)p_147046_1_, 50.0F);
            GL11.glScalef((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            float var6 = p_147046_5_.renderYawOffset;
            float var7 = p_147046_5_.rotationYaw;
            float var8 = p_147046_5_.rotationPitch;
            float var9 = p_147046_5_.prevRotationYawHead;
            float var10 = p_147046_5_.rotationYawHead;
            GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
            RenderHelper.enableStandardItemLighting();
            GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
            p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;
            p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;
            p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;
            p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;
            p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;
            GL11.glTranslatef(0.0F, p_147046_5_.yOffset, 0.0F);
            RenderManager.instance.playerViewY = 180.0F;
            p_147046_5_.renderYawOffset = var6;
            p_147046_5_.rotationYaw = var7;
            p_147046_5_.rotationPitch = var8;
            p_147046_5_.prevRotationYawHead = var9;
            p_147046_5_.rotationYawHead = var10;
            GL11.glPopMatrix();
            RenderHelper.disableStandardItemLighting();
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
        }
    
        public void drawTextureWithOptionalSize(int x, int y, int u, int v, int width, int height, int uSize, int vSize)
        {
            float scaledX = (float)1/uSize;
            float scaledY = (float)1/vSize;
            Tessellator tessellator = Tessellator.instance;
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV((double)(x + 0), (double)(y + height), (double)this.zLevel, (double)((float)(u + 0) * scaledX), (double)((float)(v + height) * scaledY));
            tessellator.addVertexWithUV((double)(x + width), (double)(y + height), (double)this.zLevel, (double)((float)(u + width) * scaledX), (double)((float)(v + height) * scaledY));
            tessellator.addVertexWithUV((double)(x + width), (double)(y + 0), (double)this.zLevel, (double)((float)(u + width) * scaledX), (double)((float)(v + 0) * scaledY));
            tessellator.addVertexWithUV((double)(x + 0), (double)(y + 0), (double)this.zLevel, (double)((float)(u + 0) * scaledX), (double)((float)(v + 0) * scaledY));
            tessellator.draw();
        }
    
        /**
         * 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 par1, int par2, float par3)
        {
            this.drawDefaultBackground();
    
            func_147046_a(this.width / 2, height / 2, 35, (float)((this.width - 176) / 2 + height / 8) - par1, (float)((this.height - 166) / 2 + 75) - par2, this.mc.thePlayer);
    
            this.drawCenteredString(this.fontRendererObj, EnumChatFormatting.GOLD + "- ThurnFight Menu -", this.width / 2, 40, 16777215);
    
            super.drawScreen(par1, par2, par3);
    
        }
    }
    

  • Administrateurs

    En fait tu as bêtement override la classe avec le même package, ce qui fonctionne sur eclipse car eclipse va compiler ta classe et la charge à la place de celle de mc, mais pas en jeu car les mécaniques de chargement sont différentes (le jar de mc est en premier dans le classpath, les mods sont ajoutés ensuite).

    Il faudrait plutôt passer par l'event GuiOpenEvent pour remplacer le gui de mc par le tiens (et faire du-coup une classe de le package de ton mod).



  • @'robin4002':

    En fait tu as bêtement override la classe avec le même package, ce qui fonctionne sur eclipse car eclipse va compiler ta classe et la charge à la place de celle de mc, mais pas en jeu car les mécaniques de chargement sont différentes (le jar de mc est en premier dans le classpath, les mods sont ajoutés ensuite).

    Il faudrait plutôt passer par l'event GuiOpenEvent pour remplacer le gui de mc par le tiens (et faire du-coup une classe de le package de ton mod).

    Comment faire alors un tuto


  • Administrateurs

    De la même façon qu'ici : https://www.minecraftforgefrance.fr/showthread.php?tid=4480#remplacermenu
    Mais en mettant GuiIngameMenu au lieu de GuiMainMenu