| 1 | package net.minecraft.client.gui.inventory;
|
| 2 |
|
| 3 | import net.minecraft.client.Minecraft;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.inventory.ContainerChest;
|
| 6 | import net.minecraft.inventory.IInventory;
|
| 7 | import net.minecraft.util.ResourceLocation;
|
| 8 |
|
| 9 | public class GuiChest extends GuiContainer
|
| 10 | {
|
| 11 | /** The ResourceLocation containing the chest GUI texture. */
|
| 12 | private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
|
| 13 | private IInventory upperChestInventory;
|
| 14 | private IInventory lowerChestInventory;
|
| 15 |
|
| 16 | /**
|
| 17 | * window height is calculated with these values; the more rows, the heigher
|
| 18 | */
|
| 19 | private int inventoryRows;
|
| 20 |
|
| 21 | public GuiChest(IInventory upperInv, IInventory lowerInv)
|
| 22 | {
|
| 23 | super(new ContainerChest(upperInv, lowerInv, Minecraft.getMinecraft().thePlayer));
|
| 24 | this.upperChestInventory = upperInv;
|
| 25 | this.lowerChestInventory = lowerInv;
|
| 26 | this.allowUserInput = false;
|
| 27 | int i = 222;
|
| 28 | int j = i - 108;
|
| 29 | this.inventoryRows = lowerInv.getSizeInventory() / 9;
|
| 30 | this.ySize = j + this.inventoryRows * 18;
|
| 31 | }
|
| 32 |
|
| 33 | /**
|
| 34 | * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
|
| 35 | */
|
| 36 | protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
| 37 | {
|
| 38 | this.fontRendererObj.drawString(this.lowerChestInventory.getDisplayName().getUnformattedText(), 8, 6, 4210752);
|
| 39 | this.fontRendererObj.drawString(this.upperChestInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
|
| 40 | }
|
| 41 |
|
| 42 | /**
|
| 43 | * Args : renderPartialTicks, mouseX, mouseY
|
| 44 | */
|
| 45 | protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
| 46 | {
|
| 47 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 48 | this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
|
| 49 | int i = (this.width - this.xSize) / 2;
|
| 50 | int j = (this.height - this.ySize) / 2;
|
| 51 | this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
|
| 52 | this.drawTexturedModalRect(i, j + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
|
| 53 | }
|
| 54 | }
|
| 55 |
|