1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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);
}
}
|