From 9d0d74a3ba0aeca9f1130d1228fa4b9ef08d19d6 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sun, 30 Mar 2014 22:59:36 +0300 Subject: Added a gui! Yaaay! --- .../jewelrycraft/container/GuiHandler.java | 38 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'common/darkknight/jewelrycraft/container/GuiHandler.java') 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; + } + } } -- cgit v1.2.3