Jump to content

Recommended Posts

Posted

I have a custom block setup to be a coal generator, everything seems to work fine until you load and process one coal in the machine. Once you close and reopen the block, the screen will flash a copy of the GUI progress bar and the top section of the GUI texture about 50% to right of the intended GUI. The original GUI is still in place but only in that short instance is there an issue.

This is my GUI class for the generator.

package com.rustygeargames.advancedtechmod.blocks.gui;

import com.rustygeargames.advancedtechmod.blocks.container.ContainerCoalGenerator;
import com.rustygeargames.advancedtechmod.tileentity.TileEntityCoalGenerator;
import com.rustygeargames.advancedtechmod.util.RefStrings;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;

public class GuiCoalGenerator extends GuiContainer
{
	private static final ResourceLocation TEXTURES = new ResourceLocation(RefStrings.MOD_ID + ":textures/gui/coal_generator.png");
	private final InventoryPlayer player;
	private final TileEntityCoalGenerator tileentity;
	
	public GuiCoalGenerator(InventoryPlayer player, TileEntityCoalGenerator tileentity) 
	{
		super(new ContainerCoalGenerator(player, tileentity));
		this.player = player;
		this.tileentity = tileentity;
	}
	

	
	private String toString(int cookProgressScaled) {
		return toString(this.getCookProgressScaled(24));
	}

	@Override
	protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) 
	{
		String tileName = this.tileentity.getDisplayName().getUnformattedText();
		String cookprogress = toString();
		this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) -5, 6, 4210752);
		this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 7, this.ySize - 96 + 2, 4210752);
		this.fontRenderer.drawString(Integer.toString(this.tileentity.getEnergyStored()), 115, 72, 4210752);
		this.fontRenderer.drawString(Integer.toString(this.tileentity.cookTime), 115, 50, 4210752);
	}
	
	@Override
	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
	{
        
		GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
		this.mc.getTextureManager().bindTexture(TEXTURES);
		this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
		
		//ArrowProgress
		int l = this.getCookProgressScaled(24);
		this.drawTexturedModalRect(this.guiLeft + 113, this.guiTop + 32, 176, 0, l + 1, 16);
		
		//EnergyBar
		int k = this.getEnergyStoredScaled(75);
		this.drawTexturedModalRect(this.guiLeft + 152, this.guiTop + 7, 176, 17, 16, 75 - k);
	}
	
	private int getEnergyStoredScaled(int pixels)
	{
		int i = this.tileentity.getEnergyStored();
		int j = this.tileentity.getMaxEnergyStored();
		return i != 0 && j != 0 ? i * pixels / j : 0; 
	}
	
	private int getCookProgressScaled(int pixels)
	{
		int i = this.tileentity.cookTime;
		return i != 0 ? i * pixels / 25 : 0;
		
	}
	
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
        this.drawDefaultBackground();
        super.drawScreen(mouseX, mouseY, partialTicks);
        this.renderHoveredToolTip(mouseX, mouseY);
    }
	

}

 

MyIssue.png

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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