Search in sources :

Example 1 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates 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)

Example 2 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsBlockGenericSubMultiBlock method getSelectedBoundingBoxFromPool.

@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
    DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
    TileEntity tile = pos.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
            if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
                if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
                    return LogisticsPipes.LogisticsPipeBlock.getSelectedBoundingBoxFromPool(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord);
                }
            }
        }
    }
    return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsBlockGenericSubMultiBlock method getPickBlock.

@Override
@SuppressWarnings("deprecation")
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
    DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
    TileEntity tile = pos.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
            if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
                if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
                    return LogisticsPipes.LogisticsPipeBlock.getPickBlock(target, world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord);
                }
            }
        }
        if (!mainPipeList.isEmpty() && mainPipeList.get(0).pipe != null && mainPipeList.get(0).pipe.isMultiBlock()) {
            return LogisticsPipes.LogisticsPipeBlock.getPickBlock(target, world, mainPipeList.get(0).xCoord, mainPipeList.get(0).yCoord, mainPipeList.get(0).zCoord);
        }
    }
    return super.getPickBlock(target, world, x, y, z);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 4 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsBlockGenericSubMultiBlock method getIcon.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "all" })
public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) {
    DoubleCoordinates pos = new DoubleCoordinates(i, j, k);
    TileEntity tile = pos.getTileEntity(iblockaccess);
    if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> mainPipe = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        if (!mainPipe.isEmpty() && mainPipe.get(0).pipe != null && mainPipe.get(0).pipe.isMultiBlock()) {
            return LogisticsPipes.LogisticsPipeBlock.getIcon(iblockaccess, mainPipe.get(0).xCoord, mainPipe.get(0).yCoord, mainPipe.get(0).zCoord, l);
        }
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 5 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsBlockGenericSubMultiBlock method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
    DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
    TileEntity tile = pos.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        boolean handled = false;
        List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
            if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
                if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
                    DoubleCoordinates mainPipePos = mainPipe.pipe.getLPPosition();
                    mainPipePos.setBlockToAir(world);
                    handled = true;
                }
            }
        }
        if (!handled) {
            mainPipeList.stream().filter(mainPipe -> mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()).forEach(mainPipe -> {
                DoubleCoordinates mainPipePos = mainPipe.pipe.getLPPosition();
                mainPipePos.setBlockToAir(world);
            });
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsPipes(logisticspipes.LogisticsPipes) Random(java.util.Random) MainProxy(logisticspipes.proxy.MainProxy) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Minecraft(net.minecraft.client.Minecraft) LPConstants(logisticspipes.LPConstants) IBlockAccess(net.minecraft.world.IBlockAccess) Vec3(net.minecraft.util.Vec3) Entity(net.minecraft.entity.Entity) BlockContainer(net.minecraft.block.BlockContainer) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) EffectRenderer(net.minecraft.client.particle.EffectRenderer) World(net.minecraft.world.World) EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) IIcon(net.minecraft.util.IIcon) List(java.util.List) Material(net.minecraft.block.material.Material) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)94 TileEntity (net.minecraft.tileentity.TileEntity)57 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)22 LPPositionSet (logisticspipes.utils.LPPositionSet)19 ArrayList (java.util.ArrayList)17 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)15 EnumFacing (net.minecraft.util.EnumFacing)14 ItemStack (net.minecraft.item.ItemStack)12 World (net.minecraft.world.World)12 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)11 Block (net.minecraft.block.Block)11 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)7 List (java.util.List)7 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)7 ILPTEInformation (logisticspipes.asm.te.ILPTEInformation)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 DockingStation (buildcraft.api.robots.DockingStation)5