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, 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.DoubleCoordinates 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.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method dropBlockAsItemWithChance.
@Override
public void dropBlockAsItemWithChance(World world, @Nonnull final BlockPos pos, @Nonnull IBlockState state, float chance, int fortune) {
if (world.isRemote) {
return;
}
int i1 = quantityDropped(world.rand);
for (int j1 = 0; j1 < i1; j1++) {
if (world.rand.nextFloat() > chance) {
continue;
}
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, pos);
if (pipe == null) {
pipe = LogisticsBlockGenericPipe.pipeRemoved.get(new DoubleCoordinates(pos));
}
if (pipe == null)
return;
if (pipe.item != null && (pipe.canBeDestroyed() || pipe.destroyByPlayer())) {
for (ItemStack stack : pipe.dropContents()) {
spawnAsEntity(world, pos, stack);
}
spawnAsEntity(world, pos, new ItemStack(pipe.item, 1, damageDropped(state)));
final NonNullList<ItemStack> list = NonNullList.create();
CoreUnroutedPipe finalPipe = pipe;
BlockAccessDelegate worldDelegate = new BlockAccessDelegate(world) {
@Override
public TileEntity getTileEntity(BlockPos testPos) {
if (pos == testPos) {
return finalPipe.container;
}
return super.getTileEntity(pos);
}
};
mcmpBlockAccess.addDrops(list, worldDelegate, pos, state, fortune);
for (ItemStack stack : list) {
spawnAsEntity(world, pos, stack);
}
} else if (pipe.item != null) {
LogisticsBlockGenericPipe.cacheTileToPreventRemoval(pipe);
}
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method checkForRenderChanges.
private void checkForRenderChanges(IBlockAccess worldIn, BlockPos blockPos) {
TileEntity tile = new DoubleCoordinates(blockPos).getTileEntity(worldIn);
if (!(tile instanceof LogisticsTileGenericPipe))
return;
((LogisticsTileGenericPipe) tile).renderState.checkForRenderUpdate(worldIn, blockPos);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method getDrops.
@Nonnull
@Override
public NonNullList<ItemStack> getDrops(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
NonNullList<ItemStack> list = NonNullList.create();
if (MainProxy.isClient(world)) {
return list;
}
Random rand = world instanceof World ? ((World) world).rand : RANDOM;
int count = quantityDropped(state, fortune, rand);
for (int i = 0; i < count; i++) {
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, pos);
if (pipe == null) {
pipe = LogisticsBlockGenericPipe.pipeRemoved.get(new DoubleCoordinates(pos));
}
if (pipe != null) {
if (pipe.item != null && (pipe.canBeDestroyed() || pipe.destroyByPlayer())) {
list.addAll(pipe.dropContents());
list.add(new ItemStack(pipe.item, 1, damageDropped(state)));
} else if (pipe.item != null) {
LogisticsBlockGenericPipe.cacheTileToPreventRemoval(pipe);
}
}
}
mcmpBlockAccess.addDrops(list, world, pos, state, fortune);
return list;
}
Aggregations