package me.Danker.containers; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; // Hopefully this is dyanmic, only tested with 63 slots public class GuiChestDynamic extends GuiContainer { private final ResourceLocation CHEST_GUI_TEXTURE; private IInventory upperChestInventory; private IInventory lowerChestInventory; private int inventoryRows; public GuiChestDynamic(IInventory upperInv, IInventory lowerInv, ResourceLocation texture) { super(new ContainerChest(upperInv, lowerInv, Minecraft.getMinecraft().thePlayer)); this.upperChestInventory = upperInv; this.lowerChestInventory = lowerInv; this.allowUserInput = false; this.inventoryRows = lowerInv.getSizeInventory() / 9; int i = this.inventoryRows * 37; int j = i - this.inventoryRows * 18; this.ySize = j + this.inventoryRows * 18; this.CHEST_GUI_TEXTURE = texture; } protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRendererObj.drawString(this.lowerChestInventory.getDisplayName().getUnformattedText(), 8, 6, 4210752); this.fontRendererObj.drawString(this.upperChestInventory.getDisplayName().getUnformattedText(), 8, this.ySize - this.inventoryRows * 16 - 1, 4210752); } protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.inventoryRows * 18 + 17); this.drawTexturedModalRect(i, j + this.inventoryRows * 18 + 17, 0, this.inventoryRows * 18 + 18, this.xSize, this.inventoryRows * 16); } }