ironbarrels/IronChests2/common/cpw/mods/ironchest/client/GUIChest.java

99 lines
3.7 KiB
Java
Raw Normal View History

/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest.client;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.ironchest.ContainerIronChestBase;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest;
public class GUIChest extends GuiContainer {
2013-07-02 19:54:03 +02:00
public enum ResourceList {
IRON(new ResourceLocation("ironchest", "textures/gui/ironcontainer.png")),
COPPER(new ResourceLocation("ironchest", "textures/gui/coppercontainer.png")),
SILVER(new ResourceLocation("ironchest", "textures/gui/silvercontainer.png")),
GOLD(new ResourceLocation("ironchest", "textures/gui/goldcontainer.png")),
2013-09-16 19:43:32 +02:00
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")),
DIRT(new ResourceLocation("ironchest", "textures/gui/dirtcontainer.png"));
2013-07-02 19:54:03 +02:00
public final ResourceLocation location;
private ResourceList(ResourceLocation loc) {
this.location = loc;
}
}
public enum GUI {
2013-07-02 19:54:03 +02:00
IRON(184, 202, ResourceList.IRON, IronChestType.IRON),
GOLD(184, 256, ResourceList.GOLD, IronChestType.GOLD),
DIAMOND(238, 256, ResourceList.DIAMOND, IronChestType.DIAMOND),
COPPER(184, 184, ResourceList.COPPER, IronChestType.COPPER),
SILVER(184, 238, ResourceList.SILVER, IronChestType.SILVER),
CRYSTAL(238, 256, ResourceList.DIAMOND, IronChestType.CRYSTAL),
2013-09-16 19:43:32 +02:00
OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN),
DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000);
private int xSize;
private int ySize;
2013-07-02 19:54:03 +02:00
private ResourceList guiResourceList;
private IronChestType mainType;
2013-07-02 19:54:03 +02:00
private GUI(int xSize, int ySize, ResourceList guiResourceList, IronChestType mainType)
{
this.xSize = xSize;
this.ySize = ySize;
2013-07-02 19:54:03 +02:00
this.guiResourceList = guiResourceList;
this.mainType = mainType;
2013-07-02 19:54:03 +02:00
}
protected Container makeContainer(IInventory player, IInventory chest)
{
return new ContainerIronChestBase(player, chest, mainType, xSize, ySize);
}
public static GUIChest buildGUI(IronChestType type, IInventory playerInventory, TileEntityIronChest chestInventory)
{
return new GUIChest(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
}
}
public int getRowLength()
{
return type.mainType.getRowLength();
}
private GUI type;
private GUIChest(GUI type, IInventory player, IInventory chest)
{
super(type.makeContainer(player, chest));
this.type = type;
this.xSize = type.xSize;
this.ySize = type.ySize;
this.allowUserInput = false;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
2013-03-04 17:18:53 +01:00
// new "bind tex"
2013-09-03 21:52:03 +02:00
this.mc.getTextureManager().bindTexture(type.guiResourceList.location);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}