Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

 

What are the values of width, height, xSize and ySize?

  • Author

they should be just the height and width of the gui

The Korecraft Mod

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.