    001package net.minecraft.client.gui.inventory;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.inventory.ContainerChest;
    006import net.minecraft.inventory.IInventory;
    007import net.minecraft.util.StatCollector;
    008import org.lwjgl.opengl.GL11;
    009
    010@SideOnly(Side.CLIENT)
    011public class GuiChest extends GuiContainer
    012{
    013    private IInventory upperChestInventory;
    014    private IInventory lowerChestInventory;
    015
    016    /**
    017     * window height is calculated with this values, the more rows, the heigher
    018     */
    019    private int inventoryRows = 0;
    020
    021    public GuiChest(IInventory par1IInventory, IInventory par2IInventory)
    022    {
    023        super(new ContainerChest(par1IInventory, par2IInventory));
    024        this.upperChestInventory = par1IInventory;
    025        this.lowerChestInventory = par2IInventory;
    026        this.allowUserInput = false;
    027        short short1 = 222;
    028        int i = short1 - 108;
    029        this.inventoryRows = par2IInventory.getSizeInventory() / 9;
    030        this.ySize = i + this.inventoryRows * 18;
    031    }
    032
    033    /**
    034     * Draw the foreground layer for the GuiContainer (everything in front of the items)
    035     */
    036    protected void drawGuiContainerForegroundLayer(int par1, int par2)
    037    {
    038        this.fontRenderer.drawString(this.lowerChestInventory.isInvNameLocalized() ? this.lowerChestInventory.getInvName() : StatCollector.translateToLocal(this.lowerChestInventory.getInvName()), 8, 6, 4210752);
    039        this.fontRenderer.drawString(this.upperChestInventory.isInvNameLocalized() ? this.upperChestInventory.getInvName() : StatCollector.translateToLocal(this.upperChestInventory.getInvName()), 8, this.ySize - 96 + 2, 4210752);
    040    }
    041
    042    /**
    043     * Draw the background layer for the GuiContainer (everything behind the items)
    044     */
    045    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    046    {
    047        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    048        this.mc.renderEngine.bindTexture("/gui/container.png");
    049        int k = (this.width - this.xSize) / 2;
    050        int l = (this.height - this.ySize) / 2;
    051        this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
    052        this.drawTexturedModalRect(k, l + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
    053    }
    054}