2012-12-18 17:22:21 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* 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
|
2016-05-19 01:47:25 +02:00
|
|
|
* <p>
|
2012-12-18 17:22:21 +01:00
|
|
|
* Contributors:
|
2016-05-19 01:47:25 +02:00
|
|
|
* cpw - initial API and implementation
|
2012-12-18 17:22:21 +01:00
|
|
|
******************************************************************************/
|
|
|
|
package cpw.mods.ironchest.client;
|
|
|
|
|
2014-02-05 19:06:35 +01:00
|
|
|
import cpw.mods.ironchest.ContainerIronChest;
|
2012-12-18 17:22:21 +01:00
|
|
|
import cpw.mods.ironchest.IronChestType;
|
|
|
|
import cpw.mods.ironchest.TileEntityIronChest;
|
2016-03-21 17:44:27 +01:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
2016-05-19 01:47:25 +02:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2016-03-21 17:44:27 +01:00
|
|
|
import net.minecraft.inventory.Container;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2012-12-18 17:22:21 +01:00
|
|
|
|
2016-03-21 17:44:27 +01:00
|
|
|
public class GUIChest extends GuiContainer
|
|
|
|
{
|
|
|
|
public enum ResourceList
|
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
//@formatter:off
|
2016-11-18 16:26:10 +01:00
|
|
|
IRON(new ResourceLocation("ironchest", "textures/gui/iron_container.png")),
|
|
|
|
COPPER(new ResourceLocation("ironchest", "textures/gui/copper_container.png")),
|
|
|
|
SILVER(new ResourceLocation("ironchest", "textures/gui/silver_container.png")),
|
|
|
|
GOLD(new ResourceLocation("ironchest", "textures/gui/gold_container.png")),
|
|
|
|
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamond_container.png")),
|
|
|
|
DIRT(new ResourceLocation("ironchest", "textures/gui/dirt_container.png"));
|
2016-05-19 01:47:25 +02:00
|
|
|
//@formatter:on
|
2013-07-02 19:54:03 +02:00
|
|
|
public final ResourceLocation location;
|
2016-03-21 17:44:27 +01:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
ResourceList(ResourceLocation loc)
|
2016-03-21 17:44:27 +01:00
|
|
|
{
|
2013-07-02 19:54:03 +02:00
|
|
|
this.location = loc;
|
|
|
|
}
|
|
|
|
}
|
2016-03-21 17:44:27 +01:00
|
|
|
|
|
|
|
public enum GUI
|
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
//@formatter:off
|
|
|
|
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),
|
|
|
|
OBSIDIAN(238, 256, ResourceList.DIAMOND,IronChestType.OBSIDIAN),
|
|
|
|
DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000);
|
|
|
|
//@formatter:on
|
2012-12-18 17:22:21 +01:00
|
|
|
|
|
|
|
private int xSize;
|
|
|
|
private int ySize;
|
2013-07-02 19:54:03 +02:00
|
|
|
private ResourceList guiResourceList;
|
2012-12-18 17:22:21 +01:00
|
|
|
private IronChestType mainType;
|
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
GUI(int xSize, int ySize, ResourceList guiResourceList, IronChestType mainType)
|
2012-12-18 17:22:21 +01:00
|
|
|
{
|
|
|
|
this.xSize = xSize;
|
|
|
|
this.ySize = ySize;
|
2013-07-02 19:54:03 +02:00
|
|
|
this.guiResourceList = guiResourceList;
|
2012-12-18 17:22:21 +01:00
|
|
|
this.mainType = mainType;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Container makeContainer(IInventory player, IInventory chest)
|
|
|
|
{
|
2016-03-21 17:44:27 +01:00
|
|
|
return new ContainerIronChest(player, chest, this.mainType, this.xSize, this.ySize);
|
2012-12-18 17:22:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static GUIChest buildGUI(IronChestType type, IInventory playerInventory, TileEntityIronChest chestInventory)
|
|
|
|
{
|
|
|
|
return new GUIChest(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
2013-03-04 17:18:53 +01:00
|
|
|
// new "bind tex"
|
2016-03-21 17:44:27 +01:00
|
|
|
this.mc.getTextureManager().bindTexture(this.type.guiResourceList.location);
|
|
|
|
int x = (this.width - this.xSize) / 2;
|
|
|
|
int y = (this.height - this.ySize) / 2;
|
|
|
|
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
|
2012-12-18 17:22:21 +01:00
|
|
|
}
|
|
|
|
}
|