summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/container/GuiHandler.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-30 22:59:36 +0300
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-30 22:59:36 +0300
commit9d0d74a3ba0aeca9f1130d1228fa4b9ef08d19d6 (patch)
tree86c2e6f3fc80cb4473b9044bdc00d0a2a082ad1b /common/darkknight/jewelrycraft/container/GuiHandler.java
parent5fce447142b3c0f4a214ca7eb208d9e5c25e6377 (diff)
Added a gui! Yaaay!
Diffstat (limited to 'common/darkknight/jewelrycraft/container/GuiHandler.java')
-rw-r--r--common/darkknight/jewelrycraft/container/GuiHandler.java38
1 files changed, 35 insertions, 3 deletions
diff --git a/common/darkknight/jewelrycraft/container/GuiHandler.java b/common/darkknight/jewelrycraft/container/GuiHandler.java
index a0afc3f..6e1a78a 100644
--- a/common/darkknight/jewelrycraft/container/GuiHandler.java
+++ b/common/darkknight/jewelrycraft/container/GuiHandler.java
@@ -6,25 +6,57 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.client.GuiGuide;
import darkknight.jewelrycraft.client.GuiRingChest;
public class GuiHandler implements IGuiHandler
{
+ public static enum GuiId {
+ ringChest,
+ guide;
+
+ public static final GuiId[] VALUES = GuiId.values();
+ }
+
public GuiHandler()
{
NetworkRegistry.instance().registerGuiHandler(JewelrycraftMod.instance, this);
}
-
+
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
- return new ContainerRingChest(player.inventory, (TileEntityChest) world.getBlockTileEntity(x, y, z));
+ final GuiId guiId = getGuiId(ID);
+ if (guiId == null) return null;
+ switch(guiId)
+ {
+ case ringChest: return new ContainerRingChest(player.inventory, (TileEntityChest) world.getBlockTileEntity(x, y, z));
+ case guide: return new ContainerGuide();
+ default: return null;
+ }
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
- return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z));
+ final GuiId guiId = getGuiId(ID);
+ if (guiId == null) return null;
+ switch(guiId)
+ {
+ case ringChest: return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z));
+ case guide: return new GuiGuide((ContainerGuide) getServerGuiElement(ID, player, world, x, y, z), world);
+ default: return null;
+ }
}
+ private static GuiId getGuiId(int id) {
+ try
+ {
+ return GuiId.VALUES[id];
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ return null;
+ }
+ }
}