use of network.rs485.logisticspipes.world.DoubleCoordinatesType in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method removePipe.
public static void removePipe(CoreUnroutedPipe pipe) {
if (!LogisticsBlockGenericPipe.isValid(pipe)) {
return;
}
if (pipe.canBeDestroyed() || pipe.destroyByPlayer()) {
pipe.onBlockRemoval();
} else if (pipe.preventRemove()) {
LogisticsBlockGenericPipe.cacheTileToPreventRemoval(pipe);
}
World world = pipe.container.getWorld();
if (LogisticsBlockGenericPipe.lastRemovedDate != world.getTotalWorldTime()) {
LogisticsBlockGenericPipe.lastRemovedDate = world.getTotalWorldTime();
LogisticsBlockGenericPipe.pipeRemoved.clear();
LogisticsBlockGenericPipe.pipeSubMultiRemoved.clear();
}
if (pipe.isMultiBlock()) {
if (pipe.preventRemove()) {
throw new UnsupportedOperationException("A multi block can't be protected against removal.");
}
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> list = ((CoreMultiBlockPipe) pipe).getRotatedSubBlocks();
list.forEach(pos -> pos.add(new DoubleCoordinates(pipe)));
for (DoubleCoordinates pos : pipe.container.subMultiBlock) {
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> equ = list.findClosest(pos);
if (equ != null) {
((LogisticsTileGenericSubMultiBlock) tile).removeSubType(equ.getType());
}
if (((LogisticsTileGenericSubMultiBlock) tile).removeMainPipe(new DoubleCoordinates(pipe))) {
LogisticsBlockGenericSubMultiBlock.redirectedToMainPipe = true;
pos.setBlockToAir(world);
LogisticsBlockGenericSubMultiBlock.redirectedToMainPipe = false;
LogisticsBlockGenericPipe.pipeSubMultiRemoved.put(new DoubleCoordinates(pos), pipe.container.getPos());
} else {
MainProxy.sendPacketToAllWatchingChunk(tile, ((LogisticsTileGenericSubMultiBlock) tile).getLPDescriptionPacket());
}
}
}
}
BlockPos pos = pipe.container.getPos();
LogisticsBlockGenericPipe.pipeRemoved.put(new DoubleCoordinates(pos), pipe);
world.removeTileEntity(pos);
}
use of network.rs485.logisticspipes.world.DoubleCoordinatesType in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method placePipe.
public static boolean placePipe(CoreUnroutedPipe pipe, World world, BlockPos blockPos, Block block, ITubeOrientation orientation) {
IBlockState oldBlockState = world.getBlockState(blockPos);
boolean placed = world.setBlockState(blockPos, block.getDefaultState(), 0);
if (world.isRemote) {
return placed;
}
if (placed) {
TileEntity tile = world.getTileEntity(blockPos);
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(blockPos);
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.getBlockPos());
IBlockState oldSubBlockState = world.getBlockState(pos.getBlockPos());
if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
((LogisticsTileGenericSubMultiBlock) subTile).addMultiBlockMainPos(placeAt);
((LogisticsTileGenericSubMultiBlock) subTile).addSubTypeTo(pos.getType());
MainProxy.sendPacketToAllWatchingChunk(subTile, ((LogisticsTileGenericSubMultiBlock) subTile).getLPDescriptionPacket());
} else {
world.setBlockState(pos.getBlockPos(), LPBlocks.subMultiblock.getDefaultState(), 0);
subTile = world.getTileEntity(pos.getBlockPos());
if (subTile instanceof LogisticsTileGenericSubMultiBlock) {
((LogisticsTileGenericSubMultiBlock) subTile).addSubTypeTo(pos.getType());
}
}
world.markAndNotifyBlock(pos.getBlockPos(), world.getChunkFromBlockCoords(pos.getBlockPos()), oldSubBlockState, world.getBlockState(pos.getBlockPos()), 3);
}
LogisticsBlockGenericSubMultiBlock.currentCreatedMultiBlock = null;
}
tilePipe.initialize(pipe);
// tilePipe.sendUpdateToClient();
}
world.markAndNotifyBlock(blockPos, world.getChunkFromBlockCoords(blockPos), oldBlockState, world.getBlockState(blockPos), 3);
}
return placed;
}
use of network.rs485.logisticspipes.world.DoubleCoordinatesType in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method addDestroyEffects.
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) {
if (super.addDestroyEffects(world, pos, effectRenderer))
return true;
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, pos);
if (pipe == null) {
return false;
}
ClientConfiguration config = LogisticsPipes.getClientPlayerConfig();
// if (config.isUseNewRenderer()) {
LogisticsNewRenderPipe.renderDestruction(pipe, world, pos.getX(), pos.getY(), pos.getZ(), effectRenderer);
/*} else {
TextureAtlasSprite icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
byte its = 4;
for (int i = 0; i < its; ++i) {
for (int j = 0; j < its; ++j) {
for (int k = 0; k < its; ++k) {
if (pipe.isMultiBlock()) {
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> set = ((CoreMultiBlockPipe) pipe).getRotatedSubBlocks();
set.add(new DoubleCoordinatesType<>(0, 0, 0, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
for (DoubleCoordinates pos : set) {
int localx = x + pos.getXInt();
int localy = y + pos.getYInt();
int localz = z + pos.getZInt();
double px = localx + (i + 0.5D) / its;
double py = localy + (j + 0.5D) / its;
double pz = localz + (k + 0.5D) / its;
int random = rand.nextInt(6);
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - localx - 0.5D, py - localy - 0.5D, pz - localz - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
fx.setParticleIcon(icon);
effectRenderer.addEffect(fx.applyColourMultiplier(pos));
}
} else {
double px = x + (i + 0.5D) / its;
double py = y + (j + 0.5D) / its;
double pz = z + (k + 0.5D) / its;
int random = rand.nextInt(6);
EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
fx.setParticleIcon(icon);
effectRenderer.addEffect(fx.applyColourMultiplier(pos));
}
}
}
}
}
*/
return true;
}
use of network.rs485.logisticspipes.world.DoubleCoordinatesType in project LogisticsPipes by RS485.
the class LogisticsTileGenericPipe method getRenderBoundingBox.
@Nonnull
@SideOnly(Side.CLIENT)
@Override
public AxisAlignedBB getRenderBoundingBox() {
if (renderBox != null) {
return renderBox;
}
if (pipe == null) {
return new AxisAlignedBB(getPos(), getPos().add(1, 1, 1));
}
if (!pipe.isMultiBlock()) {
renderBox = new AxisAlignedBB(getPos(), getPos().add(1, 1, 1));
} else {
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> set = ((CoreMultiBlockPipe) pipe).getRotatedSubBlocks();
set.addToAll(pipe.getLPPosition());
set.add(new DoubleCoordinatesType<>(getPos(), CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
set.add(new DoubleCoordinatesType<>(getPos().getX() + 1, getPos().getY() + 1, getPos().getZ() + 1, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
renderBox = new AxisAlignedBB(set.getMinXD() - 1, set.getMinYD() - 1, set.getMinZD() - 1, set.getMaxXD() + 1, set.getMaxYD() + 1, set.getMaxZD() + 1);
}
return renderBox;
}
Aggregations