Search in sources :

Example 6 with DoubleCoordinates

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

the class LogisticsBlockGenericSubMultiBlock method addHitEffects.

@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    int x = target.blockX;
    int y = target.blockY;
    int z = target.blockZ;
    DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
    TileEntity tile = pos.getTileEntity(worldObj);
    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(worldObj, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
                    CoreUnroutedPipe pipe = mainPipe.pipe;
                    if (pipe == null) {
                        return false;
                    }
                    IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
                    int sideHit = target.sideHit;
                    Block block = LogisticsPipes.LogisticsPipeBlock;
                    float b = 0.1F;
                    double px = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F)) + b + block.getBlockBoundsMinX();
                    double py = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F)) + b + block.getBlockBoundsMinY();
                    double pz = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F)) + b + block.getBlockBoundsMinZ();
                    if (sideHit == 0) {
                        py = y + block.getBlockBoundsMinY() - b;
                    }
                    if (sideHit == 1) {
                        py = y + block.getBlockBoundsMaxY() + b;
                    }
                    if (sideHit == 2) {
                        pz = z + block.getBlockBoundsMinZ() - b;
                    }
                    if (sideHit == 3) {
                        pz = z + block.getBlockBoundsMaxZ() + b;
                    }
                    if (sideHit == 4) {
                        px = x + block.getBlockBoundsMinX() - b;
                    }
                    if (sideHit == 5) {
                        px = x + block.getBlockBoundsMaxX() + b;
                    }
                    EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, 0.0D, 0.0D, 0.0D, block, sideHit, worldObj.getBlockMetadata(x, y, z));
                    fx.setParticleIcon(icon);
                    effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
                    return true;
                }
            }
        }
    }
    return super.addHitEffects(worldObj, target, effectRenderer);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) IIcon(net.minecraft.util.IIcon) Block(net.minecraft.block.Block) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 7 with DoubleCoordinates

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

the class LogisticsBlockGenericSubMultiBlock method getPickBlock.

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
    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, player);
                }
            }
        }
    }
    return super.getPickBlock(target, world, x, y, z, player);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 8 with DoubleCoordinates

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

the class CoreUnroutedPipe method getDistanceTo.

public double getDistanceTo(int destinationint, ForgeDirection ignore, ItemIdentifier ident, boolean isActive, double travled, double max, List<DoubleCoordinates> visited) {
    double lowest = Integer.MAX_VALUE;
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (ignore == dir) {
            continue;
        }
        IPipeInformationProvider information = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(container.getNextConnectedTile(dir));
        if (information != null) {
            DoubleCoordinates pos = new DoubleCoordinates(information);
            if (visited.contains(pos)) {
                continue;
            }
            visited.add(pos);
            lowest = information.getDistanceTo(destinationint, dir.getOpposite(), ident, isActive, travled, Math.min(max, lowest), visited);
            visited.remove(pos);
        }
    }
    return lowest;
}
Also used : IPipeInformationProvider(logisticspipes.routing.pathfinder.IPipeInformationProvider) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 9 with DoubleCoordinates

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

the class LogisticsBlockGenericPipe method addDestroyEffects.

/**
	 * Spawn particles for when the block is destroyed. Due to the nature of how
	 * this is invoked, the x/y/z locations are not always guaranteed to host
	 * your block. So be sure to do proper sanity checks before assuming that
	 * the location is this block.
	 *
	 * @param worldObj
	 *            The current world
	 * @param x
	 *            X position to spawn the particle
	 * @param y
	 *            Y position to spawn the particle
	 * @param z
	 *            Z position to spawn the particle
	 * @param meta
	 *            The metadata for the block before it was destroyed.
	 * @param effectRenderer
	 *            A reference to the current effect renderer.
	 * @return True to prevent vanilla break particles from spawning.
	 */
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(worldObj, x, y, z);
    if (pipe == null) {
        return false;
    }
    PlayerConfig config = LogisticsPipes.getClientPlayerConfig();
    if (config.isUseNewRenderer()) {
        LogisticsNewRenderPipe.renderDestruction(pipe, worldObj, x, y, z, effectRenderer);
    } else {
        IIcon 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(worldObj, 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(x, y, z));
                        }
                    } 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(worldObj, 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(x, y, z));
                    }
                }
            }
        }
    }
    return true;
}
Also used : EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) IIcon(net.minecraft.util.IIcon) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) PlayerConfig(logisticspipes.config.PlayerConfig) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 10 with DoubleCoordinates

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

the class PipeLogisticsChassi method isValidOrientation.

private boolean isValidOrientation(ForgeDirection connection) {
    if (connection == ForgeDirection.UNKNOWN) {
        return false;
    }
    if (getRouter().isRoutedExit(connection)) {
        return false;
    }
    DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), connection);
    TileEntity tile = pos.getTileEntity(getWorld());
    if (tile == null) {
        return false;
    }
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
        return false;
    }
    return MainProxy.checkPipesConnections(container, tile, connection);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)70 TileEntity (net.minecraft.tileentity.TileEntity)44 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)21 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)15 ArrayList (java.util.ArrayList)14 LPPositionSet (logisticspipes.utils.LPPositionSet)10 Block (net.minecraft.block.Block)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)8 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)8 ItemStack (net.minecraft.item.ItemStack)8 World (net.minecraft.world.World)8 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 IIcon (net.minecraft.util.IIcon)6 DockingStation (buildcraft.api.robots.DockingStation)5 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)5 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)4 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)4