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;
}
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);
}
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;
}
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);
}
}
}
}
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();
}
}
}
}
Aggregations