Search in sources :

Example 86 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, 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) IBlockState(net.minecraft.block.state.IBlockState) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 87 with DoubleCoordinates

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;
}
Also used : ClientConfiguration(network.rs485.logisticspipes.config.ClientConfiguration) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 88 with DoubleCoordinates

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);
        }
    }
}
Also used : BlockAccessDelegate(network.rs485.logisticspipes.proxy.mcmp.BlockAccessDelegate) BlockPos(net.minecraft.util.math.BlockPos) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack)

Example 89 with DoubleCoordinates

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 90 with DoubleCoordinates

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;
}
Also used : Random(java.util.Random) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Nonnull(javax.annotation.Nonnull)

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