use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem in project ImmersiveEngineering by BluSunrize.
the class CommonProxy method openGuiForItem.
public static void openGuiForItem(@Nonnull EntityPlayer player, @Nonnull EntityEquipmentSlot slot) {
ItemStack stack = player.getItemStackFromSlot(slot);
if (stack == null || !(stack.getItem() instanceof IGuiItem))
return;
IGuiItem gui = (IGuiItem) stack.getItem();
player.openGui(ImmersiveEngineering.instance, 100 * slot.ordinal() + gui.getGuiID(stack), player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem in project ImmersiveEngineering by BluSunrize.
the class ClientProxy method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID >= Lib.GUIID_Base_Item) {
EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID / 100];
//Slot determined, get actual ID
ID %= 100;
ItemStack item = player.getItemStackFromSlot(slot);
if (item != null && item.getItem() instanceof IGuiItem && ((IGuiItem) item.getItem()).getGuiID(item) == ID) {
if (ID == Lib.GUIID_Manual && ManualHelper.getManual() != null && OreDictionary.itemMatches(new ItemStack(IEContent.itemTool, 1, 3), item, false))
return ManualHelper.getManual().getGui();
if (ID == Lib.GUIID_Revolver && item.getItem() instanceof ItemRevolver)
return new GuiRevolver(player.inventory, world, slot, item);
if (ID == Lib.GUIID_Toolbox && item.getItem() instanceof ItemToolbox)
return new GuiToolbox(player.inventory, world, slot, item);
}
}
if (ID >= Lib.GUIID_Base_Item) {
ItemStack item = null;
for (EnumHand hand : EnumHand.values()) {
ItemStack held = player.getHeldItem(hand);
if (held != null && held.getItem() instanceof IGuiItem && ((IGuiItem) held.getItem()).getGuiID(held) == ID)
item = held;
}
if (item != null) {
}
} else {
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
if (te instanceof IGuiTile) {
Object gui = null;
if (ID == Lib.GUIID_CokeOven && te instanceof TileEntityCokeOven)
gui = new GuiCokeOven(player.inventory, (TileEntityCokeOven) te);
if (ID == Lib.GUIID_BlastFurnace && te instanceof TileEntityBlastFurnace)
gui = new GuiBlastFurnace(player.inventory, (TileEntityBlastFurnace) te);
if (ID == Lib.GUIID_WoodenCrate && te instanceof TileEntityWoodenCrate)
gui = new GuiCrate(player.inventory, (TileEntityWoodenCrate) te);
if (ID == Lib.GUIID_Workbench && te instanceof TileEntityModWorkbench)
gui = new GuiModWorkbench(player.inventory, (TileEntityModWorkbench) te);
if (ID == Lib.GUIID_Sorter && te instanceof TileEntitySorter)
gui = new GuiSorter(player.inventory, (TileEntitySorter) te);
if (ID == Lib.GUIID_Squeezer && te instanceof TileEntitySqueezer)
gui = new GuiSqueezer(player.inventory, (TileEntitySqueezer) te);
if (ID == Lib.GUIID_Fermenter && te instanceof TileEntityFermenter)
gui = new GuiFermenter(player.inventory, (TileEntityFermenter) te);
if (ID == Lib.GUIID_Refinery && te instanceof TileEntityRefinery)
gui = new GuiRefinery(player.inventory, (TileEntityRefinery) te);
if (ID == Lib.GUIID_ArcFurnace && te instanceof TileEntityArcFurnace)
gui = new GuiArcFurnace(player.inventory, (TileEntityArcFurnace) te);
if (ID == Lib.GUIID_Assembler && te instanceof TileEntityAssembler)
gui = new GuiAssembler(player.inventory, (TileEntityAssembler) te);
if (ID == Lib.GUIID_AutoWorkbench && te instanceof TileEntityAutoWorkbench)
gui = new GuiAutoWorkbench(player.inventory, (TileEntityAutoWorkbench) te);
if (ID == Lib.GUIID_Mixer && te instanceof TileEntityMixer)
gui = new GuiMixer(player.inventory, (TileEntityMixer) te);
if (ID == Lib.GUIID_Turret && te instanceof TileEntityTurret)
gui = new GuiTurret(player.inventory, (TileEntityTurret) te);
if (ID == Lib.GUIID_FluidSorter && te instanceof TileEntityFluidSorter)
gui = new GuiFluidSorter(player.inventory, (TileEntityFluidSorter) te);
if (ID == Lib.GUIID_Belljar && te instanceof TileEntityBelljar)
gui = new GuiBelljar(player.inventory, (TileEntityBelljar) te);
if (ID == Lib.GUIID_ToolboxBlock && te instanceof TileEntityToolbox)
gui = new GuiToolboxBlock(player.inventory, (TileEntityToolbox) te);
if (gui != null)
((IGuiTile) te).onGuiOpened(player, true);
return gui;
}
}
return null;
}
use of blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem in project ImmersiveEngineering by BluSunrize.
the class CommonProxy method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID >= Lib.GUIID_Base_Item) {
EntityEquipmentSlot slot = EntityEquipmentSlot.values()[ID / 100];
//Slot determined, get actual ID
ID %= 100;
ItemStack item = player.getItemStackFromSlot(slot);
if (item != null && item.getItem() instanceof IGuiItem && ((IGuiItem) item.getItem()).getGuiID(item) == ID) {
if (ID == Lib.GUIID_Revolver && item.getItem() instanceof ItemRevolver)
return new ContainerRevolver(player.inventory, world, slot, item);
if (ID == Lib.GUIID_Toolbox && item.getItem() instanceof ItemToolbox)
return new ContainerToolbox(player.inventory, world, slot, item);
}
} else {
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
if (te instanceof IGuiTile) {
Object gui = null;
if (ID == Lib.GUIID_CokeOven && te instanceof TileEntityCokeOven)
gui = new ContainerCokeOven(player.inventory, (TileEntityCokeOven) te);
if (ID == Lib.GUIID_BlastFurnace && te instanceof TileEntityBlastFurnace)
gui = new ContainerBlastFurnace(player.inventory, (TileEntityBlastFurnace) te);
if (ID == Lib.GUIID_WoodenCrate && te instanceof TileEntityWoodenCrate)
gui = new ContainerCrate(player.inventory, (TileEntityWoodenCrate) te);
if (ID == Lib.GUIID_Workbench && te instanceof TileEntityModWorkbench)
gui = new ContainerModWorkbench(player.inventory, (TileEntityModWorkbench) te);
if (ID == Lib.GUIID_Sorter && te instanceof TileEntitySorter)
gui = new ContainerSorter(player.inventory, (TileEntitySorter) te);
if (ID == Lib.GUIID_Squeezer && te instanceof TileEntitySqueezer)
gui = new ContainerSqueezer(player.inventory, (TileEntitySqueezer) te);
if (ID == Lib.GUIID_Fermenter && te instanceof TileEntityFermenter)
gui = new ContainerFermenter(player.inventory, (TileEntityFermenter) te);
if (ID == Lib.GUIID_Refinery && te instanceof TileEntityRefinery)
gui = new ContainerRefinery(player.inventory, (TileEntityRefinery) te);
if (ID == Lib.GUIID_ArcFurnace && te instanceof TileEntityArcFurnace)
gui = new ContainerArcFurnace(player.inventory, (TileEntityArcFurnace) te);
if (ID == Lib.GUIID_Assembler && te instanceof TileEntityAssembler)
gui = new ContainerAssembler(player.inventory, (TileEntityAssembler) te);
if (ID == Lib.GUIID_AutoWorkbench && te instanceof TileEntityAutoWorkbench)
gui = new ContainerAutoWorkbench(player.inventory, (TileEntityAutoWorkbench) te);
if (ID == Lib.GUIID_Mixer && te instanceof TileEntityMixer)
gui = new ContainerMixer(player.inventory, (TileEntityMixer) te);
if (ID == Lib.GUIID_Turret && te instanceof TileEntityTurret)
gui = new ContainerTurret(player.inventory, (TileEntityTurret) te);
if (ID == Lib.GUIID_FluidSorter && te instanceof TileEntityFluidSorter)
gui = new ContainerFluidSorter(player.inventory, (TileEntityFluidSorter) te);
if (ID == Lib.GUIID_Belljar && te instanceof TileEntityBelljar)
gui = new ContainerBelljar(player.inventory, (TileEntityBelljar) te);
if (ID == Lib.GUIID_ToolboxBlock && te instanceof TileEntityToolbox)
gui = new ContainerToolboxBlock(player.inventory, (TileEntityToolbox) te);
if (gui != null)
((IGuiTile) te).onGuiOpened(player, false);
return gui;
}
}
return null;
}
Aggregations