Search in sources :

Example 1 with IPipeHolder

use of buildcraft.api.transport.pipe.IPipeHolder in project BuildCraft by BuildCraft.

the class WorldSavedDataWireSystems method getEmitter.

public IWireEmitter getEmitter(WireSystem.WireElement element) {
    if (element.type == WireSystem.WireElement.Type.EMITTER_SIDE) {
        if (!emittersCache.containsKey(element)) {
            if (!world.isBlockLoaded(element.blockPos)) {
                BCLog.logger.warn("[transport.wire] Ghost loading " + element.blockPos + " to look for an emitter!");
            }
            TileEntity tile = world.getTileEntity(element.blockPos);
            if (tile instanceof IPipeHolder) {
                IPipeHolder holder = (IPipeHolder) tile;
                if (holder.getPluggable(element.emitterSide) instanceof PluggableGate) {
                    PluggableGate gate = (PluggableGate) holder.getPluggable(element.emitterSide);
                    emittersCache.put(element, gate.logic);
                }
            }
            if (!emittersCache.containsKey(element)) {
                throw new IllegalStateException("Tried to get a wire element when none existed! THIS IS A BUG " + element);
            }
        }
        return emittersCache.get(element);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PluggableGate(buildcraft.transport.plug.PluggableGate) IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder)

Example 2 with IPipeHolder

use of buildcraft.api.transport.pipe.IPipeHolder in project BuildCraft by BuildCraft.

the class PipeFlowItems method dropItem.

private void dropItem(ItemStack stack, EnumFacing side, EnumFacing motion, double speed) {
    if (stack == null || stack.isEmpty()) {
        return;
    }
    IPipeHolder holder = pipe.getHolder();
    World world = holder.getPipeWorld();
    BlockPos pos = holder.getPipePos();
    double x = pos.getX() + 0.5 + motion.getFrontOffsetX() * 0.5;
    double y = pos.getY() + 0.5 + motion.getFrontOffsetY() * 0.5;
    double z = pos.getZ() + 0.5 + motion.getFrontOffsetZ() * 0.5;
    speed += 0.01;
    speed *= 2;
    EntityItem ent = new EntityItem(world, x, y, z, stack);
    ent.motionX = motion.getFrontOffsetX() * speed;
    ent.motionY = motion.getFrontOffsetY() * speed;
    ent.motionZ = motion.getFrontOffsetZ() * speed;
    PipeEventItem.Drop drop = new PipeEventItem.Drop(holder, this, ent);
    holder.fireEvent(drop);
    if (ent.getItem().isEmpty() || ent.isDead) {
        return;
    }
    world.spawnEntity(ent);
}
Also used : IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) PipeEventItem(buildcraft.api.transport.pipe.PipeEventItem) EntityItem(net.minecraft.entity.item.EntityItem)

Example 3 with IPipeHolder

use of buildcraft.api.transport.pipe.IPipeHolder in project BuildCraft by BuildCraft.

the class BCTransportProxy method getServerGuiElement.

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
    BCTransportGuis gui = BCTransportGuis.get(id);
    if (gui == null)
        return null;
    TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
    switch(gui) {
        case FILTERED_BUFFER:
            {
                if (tile instanceof TileFilteredBuffer) {
                    TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile;
                    return new ContainerFilteredBuffer_BC8(player, filteredBuffer);
                }
                break;
            }
        case PIPE_DIAMOND:
            {
                if (tile instanceof IPipeHolder) {
                    IPipeHolder holder = (IPipeHolder) tile;
                    IPipe pipe = holder.getPipe();
                    if (pipe == null)
                        return null;
                    PipeBehaviour behaviour = pipe.getBehaviour();
                    if (behaviour instanceof PipeBehaviourDiamond) {
                        PipeBehaviourDiamond diaPipe = (PipeBehaviourDiamond) behaviour;
                        return new ContainerDiamondPipe(player, diaPipe);
                    }
                }
                break;
            }
        case PIPE_DIAMOND_WOOD:
            {
                if (tile instanceof IPipeHolder) {
                    IPipeHolder holder = (IPipeHolder) tile;
                    IPipe pipe = holder.getPipe();
                    if (pipe == null)
                        return null;
                    PipeBehaviour behaviour = pipe.getBehaviour();
                    if (behaviour instanceof PipeBehaviourWoodDiamond) {
                        PipeBehaviourWoodDiamond diaPipe = (PipeBehaviourWoodDiamond) behaviour;
                        return new ContainerDiamondWoodPipe(player, diaPipe);
                    }
                }
                break;
            }
        case PIPE_EMZULI:
            {
                if (tile instanceof IPipeHolder) {
                    IPipeHolder holder = (IPipeHolder) tile;
                    IPipe pipe = holder.getPipe();
                    if (pipe == null)
                        return null;
                    PipeBehaviour behaviour = pipe.getBehaviour();
                    if (behaviour instanceof PipeBehaviourEmzuli) {
                        PipeBehaviourEmzuli emPipe = (PipeBehaviourEmzuli) behaviour;
                        return new ContainerEmzuliPipe_BC8(player, emPipe);
                    }
                }
                break;
            }
        case GATE:
            {
                int ry = y >> 3;
                EnumFacing gateSide = EnumFacing.getFront(y & 0x7);
                tile = world.getTileEntity(new BlockPos(x, ry, z));
                if (tile instanceof IPipeHolder) {
                    IPipeHolder holder = (IPipeHolder) tile;
                    PipePluggable plug = holder.getPluggable(gateSide);
                    if (plug instanceof PluggableGate) {
                        return new ContainerGate(player, ((PluggableGate) plug).logic);
                    }
                }
                break;
            }
    }
    return null;
}
Also used : IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) PipeBehaviourEmzuli(buildcraft.transport.pipe.behaviour.PipeBehaviourEmzuli) EnumFacing(net.minecraft.util.EnumFacing) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) PipeBehaviourWoodDiamond(buildcraft.transport.pipe.behaviour.PipeBehaviourWoodDiamond) PipeBehaviourDiamond(buildcraft.transport.pipe.behaviour.PipeBehaviourDiamond) TileEntity(net.minecraft.tileentity.TileEntity) ContainerFilteredBuffer_BC8(buildcraft.transport.container.ContainerFilteredBuffer_BC8) PluggableGate(buildcraft.transport.plug.PluggableGate) TileFilteredBuffer(buildcraft.transport.tile.TileFilteredBuffer) BlockPos(net.minecraft.util.math.BlockPos) ContainerEmzuliPipe_BC8(buildcraft.transport.container.ContainerEmzuliPipe_BC8) ContainerGate(buildcraft.transport.container.ContainerGate) ContainerDiamondPipe(buildcraft.transport.container.ContainerDiamondPipe) IPipe(buildcraft.api.transport.pipe.IPipe) ContainerDiamondWoodPipe(buildcraft.transport.container.ContainerDiamondWoodPipe) PipeBehaviour(buildcraft.api.transport.pipe.PipeBehaviour)

Example 4 with IPipeHolder

use of buildcraft.api.transport.pipe.IPipeHolder in project BuildCraft by BuildCraft.

the class WireManager method updateBetweens.

@Override
public void updateBetweens(boolean recursive) {
    betweens.clear();
    parts.forEach((part, color) -> {
        for (EnumWireBetween between : EnumWireBetween.VALUES) {
            EnumWirePart[] betweenParts = between.parts;
            if (between.to == null) {
                if ((betweenParts[0] == part && getColorOfPart(betweenParts[1]) == color) || (betweenParts[1] == part && getColorOfPart(betweenParts[0]) == color)) {
                    betweens.put(between, color);
                }
            } else if (WireSystem.canWireConnect(holder, between.to)) {
                IPipe pipe = holder.getNeighbourPipe(between.to);
                if (pipe != null) {
                    IWireManager wireManager = pipe.getHolder().getWireManager();
                    if (betweenParts[0] == part && wireManager.getColorOfPart(betweenParts[1]) == color) {
                        betweens.put(between, color);
                    }
                }
            }
        }
    });
    if (!recursive) {
        for (EnumFacing side : EnumFacing.VALUES) {
            TileEntity tile = holder.getPipeWorld().getTileEntity(holder.getPipePos().offset(side));
            if (tile instanceof IPipeHolder) {
                ((IPipeHolder) tile).getWireManager().updateBetweens(true);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) EnumWirePart(buildcraft.api.transport.EnumWirePart) EnumFacing(net.minecraft.util.EnumFacing) IPipe(buildcraft.api.transport.pipe.IPipe) IWireManager(buildcraft.api.transport.IWireManager)

Example 5 with IPipeHolder

use of buildcraft.api.transport.pipe.IPipeHolder in project BuildCraft by BuildCraft.

the class ActionPowerPulsar method actionActivate.

@Override
public void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
    if (source instanceof IGate) {
        IGate gate = (IGate) source;
        IPipeHolder pipe = gate.getPipeHolder();
        PipePluggable plug = pipe.getPluggable(side);
        if (plug instanceof PluggablePulsar) {
            PluggablePulsar pulsar = (PluggablePulsar) plug;
            if (constant) {
                pulsar.enablePulsar();
            } else {
                pulsar.addSinglePulse();
            }
        }
    }
}
Also used : IGate(buildcraft.api.gates.IGate) IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) PluggablePulsar(buildcraft.transport.plug.PluggablePulsar) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Aggregations

IPipeHolder (buildcraft.api.transport.pipe.IPipeHolder)10 PipeEventItem (buildcraft.api.transport.pipe.PipeEventItem)5 TileEntity (net.minecraft.tileentity.TileEntity)5 EnumFacing (net.minecraft.util.EnumFacing)4 World (net.minecraft.world.World)4 IPipe (buildcraft.api.transport.pipe.IPipe)3 ItemStack (net.minecraft.item.ItemStack)3 BlockPos (net.minecraft.util.math.BlockPos)3 IItemTransactor (buildcraft.api.inventory.IItemTransactor)2 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)2 PluggableGate (buildcraft.transport.plug.PluggableGate)2 IGate (buildcraft.api.gates.IGate)1 EnumWirePart (buildcraft.api.transport.EnumWirePart)1 IInjectable (buildcraft.api.transport.IInjectable)1 IWireManager (buildcraft.api.transport.IWireManager)1 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 ConnectedType (buildcraft.api.transport.pipe.IPipe.ConnectedType)1 PipeBehaviour (buildcraft.api.transport.pipe.PipeBehaviour)1 PipeEventHandler (buildcraft.api.transport.pipe.PipeEventHandler)1 PipeFlow (buildcraft.api.transport.pipe.PipeFlow)1