Search in sources :

Example 1 with PluggableGate

use of buildcraft.transport.plug.PluggableGate 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 PluggableGate

use of buildcraft.transport.plug.PluggableGate in project BuildCraft by BuildCraft.

the class ItemPluggableGate method onPlace.

@Override
public PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, EnumHand hand) {
    GateVariant variant = getVariant(stack);
    SoundUtil.playBlockPlace(holder.getPipeWorld(), holder.getPipePos(), variant.material.block.getDefaultState());
    PluggableDefinition def = BCTransportPlugs.gate;
    return new PluggableGate(def, holder, side, variant);
}
Also used : PluggableGate(buildcraft.transport.plug.PluggableGate) GateVariant(buildcraft.transport.gate.GateVariant) PluggableDefinition(buildcraft.api.transport.pluggable.PluggableDefinition)

Example 3 with PluggableGate

use of buildcraft.transport.plug.PluggableGate 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)

Aggregations

PluggableGate (buildcraft.transport.plug.PluggableGate)3 IPipeHolder (buildcraft.api.transport.pipe.IPipeHolder)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IPipe (buildcraft.api.transport.pipe.IPipe)1 PipeBehaviour (buildcraft.api.transport.pipe.PipeBehaviour)1 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)1 PluggableDefinition (buildcraft.api.transport.pluggable.PluggableDefinition)1 ContainerDiamondPipe (buildcraft.transport.container.ContainerDiamondPipe)1 ContainerDiamondWoodPipe (buildcraft.transport.container.ContainerDiamondWoodPipe)1 ContainerEmzuliPipe_BC8 (buildcraft.transport.container.ContainerEmzuliPipe_BC8)1 ContainerFilteredBuffer_BC8 (buildcraft.transport.container.ContainerFilteredBuffer_BC8)1 ContainerGate (buildcraft.transport.container.ContainerGate)1 GateVariant (buildcraft.transport.gate.GateVariant)1 PipeBehaviourDiamond (buildcraft.transport.pipe.behaviour.PipeBehaviourDiamond)1 PipeBehaviourEmzuli (buildcraft.transport.pipe.behaviour.PipeBehaviourEmzuli)1 PipeBehaviourWoodDiamond (buildcraft.transport.pipe.behaviour.PipeBehaviourWoodDiamond)1 TileFilteredBuffer (buildcraft.transport.tile.TileFilteredBuffer)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1