Made tile checking when opening a GUI better

This commit is contained in:
Ellpeck 2015-09-20 20:19:02 +02:00
parent 0ad50a3e62
commit 3e0996b3da

View file

@ -25,7 +25,7 @@ public class GuiHandler implements IGuiHandler{
@Override @Override
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
TileEntityBase tile = null; 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); tile = (TileEntityBase)world.getTileEntity(x, y, z);
} }
switch(GuiTypes.values()[id]){ switch(GuiTypes.values()[id]){
@ -85,7 +85,7 @@ public class GuiHandler implements IGuiHandler{
@Override @Override
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){
TileEntityBase tile = null; 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); tile = (TileEntityBase)world.getTileEntity(x, y, z);
} }
switch(GuiTypes.values()[id]){ switch(GuiTypes.values()[id]){
@ -147,7 +147,7 @@ public class GuiHandler implements IGuiHandler{
public enum GuiTypes{ public enum GuiTypes{
FEEDER, FEEDER,
GIANT_CHEST, GIANT_CHEST,
CRAFTER, CRAFTER(false),
GRINDER, GRINDER,
GRINDER_DOUBLE, GRINDER_DOUBLE,
FURNACE_DOUBLE, FURNACE_DOUBLE,
@ -163,13 +163,23 @@ public class GuiHandler implements IGuiHandler{
PHANTOM_PLACER, PHANTOM_PLACER,
FLUID_COLLECTOR, FLUID_COLLECTOR,
COFFEE_MACHINE, COFFEE_MACHINE,
DRILL, DRILL(false),
ENERGIZER, ENERGIZER,
ENERVATOR, ENERVATOR,
XP_SOLIDIFIER, XP_SOLIDIFIER,
ORE_MAGNET, ORE_MAGNET,
CLOUD, CLOUD,
BOOK BOOK(false);
public boolean checkTileEntity;
GuiTypes(boolean checkTileEntity){
this.checkTileEntity = checkTileEntity;
}
GuiTypes(){
this(true);
}
} }
public static void init(){ public static void init(){