Jump to content

[HELP]GUI offcentered


Kore

Recommended Posts

Heres my gui code... it puts the GUI in the top left and not in the center

 

 

package kore.korecraft.mod;

 

import net.minecraft.client.gui.GuiButton;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.util.StatCollector;

 

import org.lwjgl.opengl.GL11;

 

public class GuiExpBank extends GuiContainer {

 

private TileEntityExpBank expbank;

 

        public GuiExpBank (InventoryPlayer inventoryPlayer,

        TileEntityExpBank tileEntity) {

        //the container is instanciated and passed to the superclass for handling

        super(new ContainerExpBank(inventoryPlayer, tileEntity));

        expbank = tileEntity;

        }

 

        @Override

        protected void drawGuiContainerForegroundLayer(int param1, int param2) {

        //draw text and stuff here

        //the parameters for drawString are: string, x, y, color

        fontRenderer.drawString("Exp Bank", 8, 6, 4210752);

          //draws "Inventory" or your regional equivalent

      fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);

        }

 

        @Override

        protected void drawGuiContainerBackgroundLayer(float par1, int par2,

                        int par3) {

                //draw your Gui here, only thing you need to change is the path

                int texture = mc.renderEngine.getTexture("/Korecraft/GUI/ExpBank.png");

                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

                this.mc.renderEngine.bindTexture(texture);

                int x = (width - xSize) / 2;

                int y = (height - ySize) / 2;

                this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

        }

       

        public void initGui() {

    this.controlList.clear();

 

    int posX = (this.width - xSize) / 2;

    int posY = (this.height - ySize) / 2;

 

    GuiButton button1 = new GuiButton(0, 15, 70, 20, 10, "- 10");

    GuiButton button2 = new GuiButton(1, 40, 70, 20, 10, "- 1");

    GuiButton button3 = new GuiButton(2, 65, 70, 20, 10, "+ 1");

    GuiButton button4 = new GuiButton(3, 90, 70, 20, 10, "+ 10");

 

    this.controlList.add(button1);

    this.controlList.add(button2);

    this.controlList.add(button3);

    this.controlList.add(button4);

    }

   

    public void actionPerformed(GuiButton button)

    {

    switch(button.id)

    {

    case 0:

    default:

    }

    }

}

 

 

The Korecraft Mod

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.