From 3e0996b3da8584e44d36bb46cd7b43bc0a803e3a Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 20 Sep 2015 20:19:02 +0200 Subject: [PATCH] Made tile checking when opening a GUI better --- .../inventory/GuiHandler.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index 26fd21167..07bcd446c 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -25,7 +25,7 @@ public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ TileEntityBase tile = null; - if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal() && id != GuiTypes.BOOK.ordinal()){ + if(GuiTypes.values()[id].checkTileEntity){ tile = (TileEntityBase)world.getTileEntity(x, y, z); } switch(GuiTypes.values()[id]){ @@ -85,7 +85,7 @@ public class GuiHandler implements IGuiHandler{ @Override public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ TileEntityBase tile = null; - if(id != GuiTypes.CRAFTER.ordinal() && id != GuiTypes.DRILL.ordinal() && id != GuiTypes.BOOK.ordinal()){ + if(GuiTypes.values()[id].checkTileEntity){ tile = (TileEntityBase)world.getTileEntity(x, y, z); } switch(GuiTypes.values()[id]){ @@ -147,7 +147,7 @@ public class GuiHandler implements IGuiHandler{ public enum GuiTypes{ FEEDER, GIANT_CHEST, - CRAFTER, + CRAFTER(false), GRINDER, GRINDER_DOUBLE, FURNACE_DOUBLE, @@ -163,13 +163,23 @@ public class GuiHandler implements IGuiHandler{ PHANTOM_PLACER, FLUID_COLLECTOR, COFFEE_MACHINE, - DRILL, + DRILL(false), ENERGIZER, ENERVATOR, XP_SOLIDIFIER, ORE_MAGNET, CLOUD, - BOOK + BOOK(false); + + public boolean checkTileEntity; + + GuiTypes(boolean checkTileEntity){ + this.checkTileEntity = checkTileEntity; + } + + GuiTypes(){ + this(true); + } } public static void init(){