Search in sources :

Example 1 with TileEntityCokeOven

use of blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven in project ImmersiveEngineering by BluSunrize.

the class MultiblockCokeOven method createStructure.

@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
    EnumFacing f = EnumFacing.fromAngle(player.rotationYaw);
    pos = pos.offset(f);
    for (int h = -1; h <= 1; h++) for (int xx = -1; xx <= 1; xx++) for (int zz = -1; zz <= 1; zz++) {
        if (!Utils.isBlockAt(world, pos.add(xx, h, zz), IEContent.blockStoneDecoration, BlockTypes_StoneDecoration.COKEBRICK.getMeta()))
            return false;
    }
    ItemStack hammer = player.getHeldItemMainhand().getItem().getToolClasses(player.getHeldItemMainhand()).contains(Lib.TOOL_HAMMER) ? player.getHeldItemMainhand() : player.getHeldItemOffhand();
    if (MultiblockHandler.fireMultiblockFormationEventPost(player, this, pos, hammer).isCanceled())
        return false;
    IBlockState state = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.COKE_OVEN.getMeta());
    state = state.withProperty(IEProperties.FACING_HORIZONTAL, f.getOpposite());
    for (int h = -1; h <= 1; h++) for (int l = -1; l <= 1; l++) for (int w = -1; w <= 1; w++) {
        int xx = f == EnumFacing.EAST ? l : f == EnumFacing.WEST ? -l : f == EnumFacing.NORTH ? -w : w;
        int zz = f == EnumFacing.NORTH ? l : f == EnumFacing.SOUTH ? -l : f == EnumFacing.EAST ? w : -w;
        world.setBlockState(pos.add(xx, h, zz), state);
        BlockPos pos2 = pos.add(xx, h, zz);
        TileEntity curr = world.getTileEntity(pos2);
        if (curr instanceof TileEntityCokeOven) {
            TileEntityCokeOven currBlast = (TileEntityCokeOven) curr;
            currBlast.offset = new int[] { xx, h, zz };
            currBlast.pos = (h + 1) * 9 + (l + 1) * 3 + (w + 1);
            currBlast.formed = true;
            currBlast.markDirty();
            world.addBlockEvent(pos2, IEContent.blockStoneDevice, 255, 0);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityCokeOven(blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileEntityCokeOven

use of blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven 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.isEmpty() && item.getItem() instanceof IGuiItem && ((IGuiItem) item.getItem()).getGuiID(item) == ID) {
            if (ID == Lib.GUIID_Revolver && item.getItem() instanceof IEItemInterfaces.IBulletContainer)
                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);
            if (ID == Lib.GUIID_MaintenanceKit && item.getItem() instanceof ItemMaintenanceKit)
                return new ContainerMaintenanceKit(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_AlloySmelter && te instanceof TileEntityAlloySmelter)
                gui = new ContainerAlloySmelter(player.inventory, (TileEntityAlloySmelter) 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, world, (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;
}
Also used : TileEntityModWorkbench(blusunrize.immersiveengineering.common.blocks.wooden.TileEntityModWorkbench) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) IGuiItem(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem) IEItemInterfaces(blusunrize.immersiveengineering.common.items.IEItemInterfaces) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCokeOven(blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven) TileEntitySorter(blusunrize.immersiveengineering.common.blocks.wooden.TileEntitySorter) TileEntityBlastFurnace(blusunrize.immersiveengineering.common.blocks.stone.TileEntityBlastFurnace) BlockPos(net.minecraft.util.math.BlockPos) TileEntityFluidSorter(blusunrize.immersiveengineering.common.blocks.wooden.TileEntityFluidSorter) ItemToolbox(blusunrize.immersiveengineering.common.items.ItemToolbox) TileEntityAlloySmelter(blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter) IGuiTile(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile) TileEntityWoodenCrate(blusunrize.immersiveengineering.common.blocks.wooden.TileEntityWoodenCrate) ItemMaintenanceKit(blusunrize.immersiveengineering.common.items.ItemMaintenanceKit) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityCokeOven (blusunrize.immersiveengineering.common.blocks.stone.TileEntityCokeOven)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 IGuiTile (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IGuiTile)1 TileEntityAlloySmelter (blusunrize.immersiveengineering.common.blocks.stone.TileEntityAlloySmelter)1 TileEntityBlastFurnace (blusunrize.immersiveengineering.common.blocks.stone.TileEntityBlastFurnace)1 TileEntityFluidSorter (blusunrize.immersiveengineering.common.blocks.wooden.TileEntityFluidSorter)1 TileEntityModWorkbench (blusunrize.immersiveengineering.common.blocks.wooden.TileEntityModWorkbench)1 TileEntitySorter (blusunrize.immersiveengineering.common.blocks.wooden.TileEntitySorter)1 TileEntityWoodenCrate (blusunrize.immersiveengineering.common.blocks.wooden.TileEntityWoodenCrate)1 IEItemInterfaces (blusunrize.immersiveengineering.common.items.IEItemInterfaces)1 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)1 ItemMaintenanceKit (blusunrize.immersiveengineering.common.items.ItemMaintenanceKit)1 ItemToolbox (blusunrize.immersiveengineering.common.items.ItemToolbox)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 EnumFacing (net.minecraft.util.EnumFacing)1