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;
}
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);
}
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);
}
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;
}
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);
});
}
}
}
Aggregations