Search in sources :

Example 16 with TileEntity

use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.

the class CraftingSetType method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    TileEntity table = this.getTile(player.getEntityWorld(), TileEntity.class);
    if (table instanceof LogisticsCraftingTableTileEntity) {
        ((LogisticsCraftingTableTileEntity) table).targetType = targetType;
        ((LogisticsCraftingTableTileEntity) table).cacheRecipe();
    } else if (table instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) table).pipe instanceof PipeBlockRequestTable) {
        ((PipeBlockRequestTable) ((LogisticsTileGenericPipe) table).pipe).targetType = targetType;
        ((PipeBlockRequestTable) ((LogisticsTileGenericPipe) table).pipe).cacheRecipe();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)

Example 17 with TileEntity

use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.

the class LogicControllerPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    ILogicControllerTile tile = this.getTile(player.getEntityWorld(), ILogicControllerTile.class);
    if (tile == null) {
        return;
    }
    NewGuiHandler.getGui(LogicControllerGuiProvider.class).setTilePos((TileEntity) tile).open(player);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILogicControllerTile(logisticspipes.logic.interfaces.ILogicControllerTile)

Example 18 with TileEntity

use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.

the class LogicControllerGuiProvider method getContainer.

@Override
public Container getContainer(EntityPlayer player) {
    TileEntity pipe = this.getTile(player.getEntityWorld(), TileEntity.class);
    if (pipe instanceof ILogicControllerTile) {
        LogicController controller = ((ILogicControllerTile) pipe).getLogicController();
        DummyContainer dummy = new DummyContainer(player.inventory, null);
        dummy.addNormalSlotsForPlayerInventory(50, 190);
        return dummy;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DummyContainer(logisticspipes.utils.gui.DummyContainer) ILogicControllerTile(logisticspipes.logic.interfaces.ILogicControllerTile) LogicController(logisticspipes.logic.LogicController)

Example 19 with TileEntity

use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method addCollisionBoxesToList.

@Override
@SuppressWarnings({ "rawtypes" })
public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, List arraylist, Entity par7Entity) {
    TileEntity tile = world.getTileEntity(i, j, k);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
        setBlockBounds(0, 0, 0, 1, 1, 1);
        super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        return;
    }
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe != null && ((LogisticsTileGenericPipe) tile).pipe.isMultiBlock()) {
        ((CoreMultiBlockPipe) ((LogisticsTileGenericPipe) tile).pipe).addCollisionBoxesToList(arraylist, axisalignedbb);
        if (!((LogisticsTileGenericPipe) tile).pipe.actAsNormalPipe()) {
            return;
        }
    }
    setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
    super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
    if (tile instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe tileG = (LogisticsTileGenericPipe) tile;
        if (tileG.isPipeConnected(ForgeDirection.WEST)) {
            setBlockBounds(0.0F, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.EAST)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, 1.0F, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.DOWN)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, 0.0F, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.UP)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, 1.0F, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.NORTH)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, 0.0F, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.isPipeConnected(ForgeDirection.SOUTH)) {
            setBlockBounds(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        float facadeThickness = LPConstants.FACADE_THICKNESS;
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.EAST)) {
            setBlockBounds(1 - facadeThickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.WEST)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, facadeThickness, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.UP)) {
            setBlockBounds(0.0F, 1 - facadeThickness, 0.0F, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.DOWN)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, facadeThickness, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.SOUTH)) {
            setBlockBounds(0.0F, 0.0F, 1 - facadeThickness, 1.0F, 1.0F, 1.0F);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
        if (tileG.tilePart.hasEnabledFacade(ForgeDirection.NORTH)) {
            setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, facadeThickness);
            super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
        }
    }
    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable)

Example 20 with TileEntity

use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method placePipe.

public static boolean placePipe(CoreUnroutedPipe pipe, World world, int i, int j, int k, Block block, int meta, ITubeOrientation orientation) {
    if (world.isRemote) {
        return true;
    }
    boolean placed = world.setBlock(i, j, k, block, meta, 2);
    if (placed) {
        TileEntity tile = world.getTileEntity(i, j, k);
        if (tile instanceof LogisticsTileGenericPipe) {
            LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) tile;
            if (pipe instanceof CoreMultiBlockPipe) {
                if (orientation == null) {
                    throw new NullPointerException();
                }
                CoreMultiBlockPipe mPipe = (CoreMultiBlockPipe) pipe;
                orientation.setOnPipe(mPipe);
                DoubleCoordinates placeAt = new DoubleCoordinates(i, j, k);
                LogisticsBlockGenericSubMultiBlock.currentCreatedMultiBlock = placeAt;
                LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = ((CoreMultiBlockPipe) pipe).getSubBlocks();
                orientation.rotatePositions(positions);
                for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : positions) {
                    pos.add(placeAt);
                    TileEntity subTile = world.getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                    if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
                        ((LogisticsTileGenericSubMultiBlock) subTile).addMultiBlockMainPos(placeAt);
                        ((LogisticsTileGenericSubMultiBlock) subTile).addSubTypeTo(pos.getType());
                        MainProxy.sendPacketToAllWatchingChunk(subTile, ((LogisticsTileGenericSubMultiBlock) subTile).getLPDescriptionPacket());
                    } else {
                        world.setBlock(pos.getXInt(), pos.getYInt(), pos.getZInt(), LogisticsPipes.LogisticsSubMultiBlock, 0, 2);
                        subTile = world.getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                        if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
                            ((LogisticsTileGenericSubMultiBlock) subTile).addSubTypeTo(pos.getType());
                        }
                    }
                    world.notifyBlockChange(pos.getXInt(), pos.getYInt(), pos.getZInt(), LogisticsPipes.LogisticsSubMultiBlock);
                }
                LogisticsBlockGenericSubMultiBlock.currentCreatedMultiBlock = null;
            }
            tilePipe.initialize(pipe);
            tilePipe.sendUpdateToClient();
        }
        world.notifyBlockChange(i, j, k, block);
    }
    return placed;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)822 ItemStack (net.minecraft.item.ItemStack)149 BlockPos (net.minecraft.util.math.BlockPos)130 Block (net.minecraft.block.Block)83 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)76 EnumFacing (net.minecraft.util.EnumFacing)62 ArrayList (java.util.ArrayList)61 IBlockState (net.minecraft.block.state.IBlockState)61 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 IInventory (net.minecraft.inventory.IInventory)49 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)44 World (net.minecraft.world.World)43 EntityItem (net.minecraft.entity.item.EntityItem)39 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)35 FluidStack (net.minecraftforge.fluids.FluidStack)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 HashMap (java.util.HashMap)25 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)23 AMVector3 (am2.api.math.AMVector3)21 Entity (net.minecraft.entity.Entity)21