Search in sources :

Example 1 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project LogisticsPipes by RS485.

the class LPBCTileGenericPipe method updateEntity_LP.

@Override
@SneakyThrows({ NoSuchFieldException.class, SecurityException.class, IllegalArgumentException.class, IllegalAccessException.class, NoSuchMethodException.class, InvocationTargetException.class })
public void updateEntity_LP() {
    //Make sure we still have the same TE values
    xCoord = lpPipe.xCoord;
    yCoord = lpPipe.yCoord;
    zCoord = lpPipe.zCoord;
    if (attachPluggables) {
        attachPluggables = false;
        // Attach callback
        PipePluggable[] pluggables = ReflectionHelper.getPrivateField(PipePluggable[].class, SideProperties.class, "pluggables", sideProperties);
        for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
            if (pluggables[i] != null) {
                pipe.eventBus.registerHandler(pluggables[i]);
                pluggables[i].onAttachedPipe(this, ForgeDirection.getOrientation(i));
            }
        }
        notifyBlockChanged();
    }
    if (!BlockGenericPipe.isValid(pipe)) {
        return;
    }
    pipe.updateEntity();
    boolean recheckThisPipe = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        PipePluggable p = getPipePluggable(direction);
        if (p != null) {
            p.update(this, direction);
            //Check Gate for ActionChanges
            if (p instanceof GatePluggable && lpPipe.isRoutingPipe()) {
                if (!activeActions.containsKey(direction)) {
                    activeActions.put(direction, new ArrayList<>());
                }
                if (!listEquals(activeActions.get(direction), pipe.gates[direction.ordinal()].activeActions)) {
                    activeActions.get(direction).clear();
                    activeActions.get(direction).addAll(pipe.gates[direction.ordinal()].activeActions);
                    lpPipe.getRoutingPipe().triggerConnectionCheck();
                    recheckThisPipe = true;
                }
            } else if (activeActions.containsKey(direction)) {
                activeActions.remove(direction);
            }
            if (p instanceof RobotStationPluggable) {
                if (((RobotStationPluggable) p).getStation() != null && ((RobotStationPluggable) p).getStation().robotTaking() != null && ((RobotStationPluggable) p).getStation().robotTaking().getBoard() instanceof LogisticsRoutingBoardRobot) {
                    ((RobotStationPluggable) p).getStation().robotTaking().getBoard().cycle();
                }
            }
        }
    }
    if (recheckThisPipe) {
        LPRobotConnectionControl.instance.checkAll(worldObj);
    }
    if (worldObj.isRemote) {
        if (resyncGateExpansions) {
            ReflectionHelper.invokePrivateMethod(Object.class, TileGenericPipe.class, this, "syncGateExpansions", new Class[] {}, new Object[] {});
        }
        return;
    }
    if (blockNeighborChange) {
        //ReflectionHelper.invokePrivateMethod(Object.class, TileGenericPipe.class, this, "computeConnections", new Class[]{}, new Object[]{});
        pipe.onNeighborBlockChange(0);
        blockNeighborChange = false;
        refreshRenderState = true;
    }
    if (refreshRenderState) {
        refreshRenderState();
        refreshRenderState = false;
    }
}
Also used : RobotStationPluggable(buildcraft.robotics.RobotStationPluggable) LogisticsRoutingBoardRobot(logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) GatePluggable(buildcraft.transport.gates.GatePluggable) SneakyThrows(lombok.SneakyThrows)

Example 2 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class TilePipeHolder method replacePluggable.

public PipePluggable replacePluggable(EnumFacing side, PipePluggable with) {
    redstoneValues = new int[6];
    PluggableHolder holder = pluggables.get(side);
    PipePluggable old = holder.pluggable;
    holder.pluggable = with;
    eventBus.unregisterHandler(old);
    eventBus.registerHandler(with);
    if (pipe != null) {
        pipe.markForUpdate();
    }
    if (!world.isRemote && old != with) {
        wireManager.getWireSystems().rebuildWireSystemsAround(this);
    }
    scheduleNetworkUpdate(PipeMessageReceiver.PLUGGABLES[side.getIndex()]);
    scheduleRenderUpdate();
    world.neighborChanged(pos.offset(side), BCTransportBlocks.pipeHolder, pos);
    return old;
}
Also used : PluggableHolder(buildcraft.transport.pipe.PluggableHolder) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 3 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class BlockPipeHolder method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> toDrop, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    TilePipeHolder tile = getPipe(world, pos, false);
    for (EnumFacing face : EnumFacing.VALUES) {
        PipePluggable pluggable = tile.getPluggable(face);
        if (pluggable != null) {
            pluggable.addDrops(toDrop, fortune);
        }
    }
    for (EnumDyeColor color : tile.wireManager.parts.values()) {
        toDrop.add(new ItemStack(BCTransportItems.wire, 1, color.getMetadata()));
    }
    Pipe pipe = tile.getPipe();
    if (pipe != null) {
        pipe.addDrops(toDrop, fortune);
    }
}
Also used : TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Pipe(buildcraft.transport.pipe.Pipe) ItemStack(net.minecraft.item.ItemStack) EnumDyeColor(net.minecraft.item.EnumDyeColor)

Example 4 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class BlockPipeHolder method getExplosionResistance.

@Override
public float getExplosionResistance(World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) {
    if (exploder != null) {
        Vec3d subtract = exploder.getPositionVector().subtract(new Vec3d(pos).add(VecUtil.VEC_HALF)).normalize();
        EnumFacing side = Arrays.stream(EnumFacing.VALUES).min(Comparator.comparing(facing -> new Vec3d(facing.getDirectionVec()).distanceTo(subtract))).orElseThrow(IllegalArgumentException::new);
        TilePipeHolder tile = getPipe(world, pos, true);
        if (tile != null) {
            PipePluggable pluggable = tile.getPluggable(side);
            if (pluggable != null) {
                float explosionResistance = pluggable.getExplosionResistance(exploder, explosion);
                if (explosionResistance > 0) {
                    return explosionResistance;
                }
            }
        }
    }
    return super.getExplosionResistance(world, pos, exploder, explosion);
}
Also used : TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with PipePluggable

use of buildcraft.api.transport.pluggable.PipePluggable in project BuildCraft by BuildCraft.

the class BlockPipeHolder method rayTrace.

@Nullable
public RayTraceResult rayTrace(World world, BlockPos pos, Vec3d start, Vec3d end) {
    TilePipeHolder tile = getPipe(world, pos, false);
    if (tile == null) {
        return computeTrace(null, pos, start, end, FULL_BLOCK_AABB, 400);
    }
    RayTraceResult best = null;
    Pipe pipe = tile.getPipe();
    boolean computed = false;
    if (pipe != null) {
        computed = true;
        best = computeTrace(best, pos, start, end, BOX_CENTER, 0);
        for (EnumFacing face : EnumFacing.VALUES) {
            float conSize = pipe.getConnectedDist(face);
            if (conSize > 0) {
                AxisAlignedBB aabb = BOX_FACES[face.ordinal()];
                if (conSize != 0.25f) {
                    Vec3d center = VecUtil.offset(new Vec3d(0.5, 0.5, 0.5), face, 0.25 + (conSize / 2));
                    Vec3d radius = new Vec3d(0.25, 0.25, 0.25);
                    radius = VecUtil.replaceValue(radius, face.getAxis(), conSize / 2);
                    Vec3d min = center.subtract(radius);
                    Vec3d max = center.add(radius);
                    aabb = BoundingBoxUtil.makeFrom(min, max);
                }
                best = computeTrace(best, pos, start, end, aabb, face.ordinal() + 1);
            }
        }
    }
    for (EnumFacing face : EnumFacing.VALUES) {
        PipePluggable pluggable = tile.getPluggable(face);
        if (pluggable != null) {
            AxisAlignedBB bb = pluggable.getBoundingBox();
            best = computeTrace(best, pos, start, end, bb, face.ordinal() + 1 + 6);
            computed = true;
        }
    }
    for (EnumWirePart part : tile.getWireManager().parts.keySet()) {
        best = computeTrace(best, pos, start, end, part.boundingBox, part.ordinal() + 1 + 6 + 6);
        computed = true;
    }
    for (EnumWireBetween between : tile.getWireManager().betweens.keySet()) {
        best = computeTrace(best, pos, start, end, between.boundingBox, between.ordinal() + 1 + 6 + 6 + 8);
        computed = true;
    }
    if (!computed) {
        return computeTrace(null, pos, start, end, FULL_BLOCK_AABB, 400);
    }
    return best;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TilePipeHolder(buildcraft.transport.tile.TilePipeHolder) EnumWirePart(buildcraft.api.transport.EnumWirePart) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) Pipe(buildcraft.transport.pipe.Pipe) Vec3d(net.minecraft.util.math.Vec3d) EnumWireBetween(buildcraft.transport.wire.EnumWireBetween) Nullable(javax.annotation.Nullable)

Aggregations

PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)30 EnumFacing (net.minecraft.util.EnumFacing)17 TilePipeHolder (buildcraft.transport.tile.TilePipeHolder)10 Pipe (buildcraft.transport.pipe.Pipe)6 DockingStation (buildcraft.api.robots.DockingStation)5 EnumWirePart (buildcraft.api.transport.EnumWirePart)5 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)5 TileEntity (net.minecraft.tileentity.TileEntity)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 EnumWireBetween (buildcraft.transport.wire.EnumWireBetween)4 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)4 ItemStack (net.minecraft.item.ItemStack)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 IPipe (buildcraft.api.transport.pipe.IPipe)3 TileGenericPipe (buildcraft.transport.TileGenericPipe)3 LogisticsRoutingBoardRobot (logisticspipes.proxy.buildcraft.robots.boards.LogisticsRoutingBoardRobot)3 Vec3d (net.minecraft.util.math.Vec3d)3 IPipeTile (buildcraft.api.transport.IPipeTile)2 IPipeHolder (buildcraft.api.transport.pipe.IPipeHolder)2