Jump to content

[1.7.10][SOLVED]Gui not centered on screen after adding buttons.


dude22072

Recommended Posts

EDIT:Solved by calling "super.initGui();" in my initGUi();

 

Before adding my buttons, my GUI appears as such:

After adding buttons, it appears as this:

 

(also there's that weird brown thing on the gui aswell. Plus it seems to break NEI.)

My GUI class (with the buttons added):

package dudesmods.fancycheeses.gui;

import org.lwjgl.opengl.GL11;

import dudesmods.fancycheeses.container.ContainerCheeseMaker;
import dudesmods.fancycheeses.tileentity.TileEntityCheeseMaker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;

public class GuiCheeseMaker extends GuiContainer {

public static final ResourceLocation bground = new ResourceLocation("fancycheeses", "textures/gui/GuiCheeseMaker.png");

public TileEntityCheeseMaker cheeseMaker;

public GuiCheeseMaker(InventoryPlayer inventoryPlayer, TileEntityCheeseMaker entity) {
	super(new ContainerCheeseMaker(inventoryPlayer, entity));

	this.cheeseMaker = entity;

	this.xSize = 176;
	this.ySize = 166;


}

@Override
public void initGui() {
	this.buttonList.add(new GuiButton(0, 70, 20, 10, 14, "<"));
	this.buttonList.add(new GuiButton(1, 98, 20, 10, 14, ">"));
}

@Override
public void actionPerformed(GuiButton button) {
	switch(button.id) {
	case 0:
		if(cheeseMaker.cheeseToMake > 0) {
			cheeseMaker.cheeseToMake--;
		}
		break;
	case 1:
		if(cheeseMaker.cheeseToMake < 4) {
			cheeseMaker.cheeseToMake++;
		}
		break;
	default: break;
	}
}

public void drawGuiContainerForegroundLayer(int par1, int par2) {
	String name = this.cheeseMaker.hasCustomInventoryName() ? this.cheeseMaker.getInventoryName() : I18n.format(this.cheeseMaker.getInventoryName(), new Object[0]);

	this.fontRendererObj.drawString(name, (this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2) + 40, 4, 4210752);
	this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);


}

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
	guiDraw(bground);
	guiDrawLiquid("sheep_milk", guiLeft + 29, guiTop + 33, 20, 50);
	guiDrawLiquid("goat_milk", guiLeft + 50, guiTop + 33, 20, 50);


	//TODO : Might re-use this stuff?
	/*
	//Flames
	if(this.cheeseMaker.isBurning()) {
		int k = this.cheeseMaker.getBurnTimeRemainingScaled(12);
		int j = 40 - k;

        this.drawTexturedModalRect(guiLeft + 26, guiTop + 50 + 12 - k, 176, 12 - k, 14, k + 2);
	}

	//Progress Arrow
	int k = this.cheeseMaker.getCookProgressScaled(24);
	this.drawTexturedModalRect(guiLeft + 95, guiTop + 18, 176, 14, k + 1, 16);
	*/
}

protected void guiDraw(ResourceLocation var1) {
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	Minecraft.getMinecraft().getTextureManager().bindTexture(var1);
	this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
}

protected void guiDrawLiquid(String fluidName, int x, int y, int fluidAmount, int fluidCapacity) {
	if(fluidAmount > 50) {
		fluidAmount = 50;
		System.out.println("ERROR: Cheese Maker conatins more " + fluidName + " than it possibly should!");
	}
	Fluid fluid = FluidRegistry.getFluid(fluidName);
	Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
	//RenderUtil.setIntColor3(fluid.getColor());
	IIcon icon = fluid.getStillIcon();
	double height = 1;
	height = fluidAmount;
	height = height / fluidCapacity;
	height = height * 100;
	height = height / 2.33;
	GL11.glEnable(GL11.GL_BLEND);
	this.drawTexturedModelRectFromIcon(x, (int) ((y - (20 * 65 / 50))), icon != null ? icon : fluid.getBlock().getIcon(0, 0), 16, (int) Math.round(height));
	GL11.glDisable(GL11.GL_BLEND);
}

}

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

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.