use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeFlowFluids method getDebugInfo.
// IDebuggable
@Override
public void getDebugInfo(List<String> left, List<String> right, EnumFacing side) {
boolean isRemote = pipe.getHolder().getPipeWorld().isRemote;
FluidStack fluid = isRemote ? getFluidStackForRender() : currentFluid;
left.add(" - FluidType = " + (fluid == null ? "empty" : fluid.getLocalizedName()));
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (section == null) {
continue;
}
StringBuilder line = new StringBuilder(" - " + LocaleUtil.localizeFacing(part.face) + " = ");
int amount = isRemote ? section.target : section.amount;
line.append(amount > 0 ? TextFormatting.GREEN : "");
line.append(amount).append("").append(TextFormatting.RESET).append("mB");
line.append(" ").append(section.getCurrentDirection()).append(" (").append(section.ticksInDirection).append(")");
line.append(" [");
int last = -1;
int skipped = 0;
for (int i : section.incoming) {
if (i != last) {
if (skipped > 0) {
line.append("...").append(skipped).append("... ");
skipped = 0;
}
last = i;
line.append(i).append(", ");
} else {
skipped++;
}
}
if (skipped > 0) {
line.append("...").append(skipped).append("... ");
skipped = 0;
}
line.append("0]");
left.add(line.toString());
}
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class ActionType method readFromBuffer.
@Override
public ActionWrapper readFromBuffer(PacketBufferBC buffer) throws IOException {
if (buffer.readBoolean()) {
String name = buffer.readString();
EnumPipePart part = buffer.readEnumValue(EnumPipePart.class);
IStatement statement = StatementManager.statements.get(name);
if (statement instanceof IAction) {
return ActionWrapper.wrap(statement, part.face);
} else {
throw new InvalidInputDataException("Unknown action '" + name + "'");
}
} else {
return null;
}
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class TriggerType method readFromBuffer.
@Override
public TriggerWrapper readFromBuffer(PacketBufferBC buffer) throws IOException {
if (buffer.readBoolean()) {
String name = buffer.readString();
EnumPipePart part = buffer.readEnumValue(EnumPipePart.class);
IStatement statement = StatementManager.statements.get(name);
if (statement instanceof ITrigger) {
return TriggerWrapper.wrap(statement, part.face);
} else {
throw new InvalidInputDataException("Unknown trigger '" + name + "'");
}
} else {
return null;
}
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class BlockPipeHolder method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
TilePipeHolder tile = getPipe(world, pos, false);
if (tile == null) {
return false;
}
RayTraceResult trace = rayTrace(world, pos, player);
if (trace == null) {
return false;
}
EnumFacing realSide = getPartSideHit(trace);
if (realSide == null) {
realSide = side;
}
if (trace.subHit > 6 && trace.subHit <= 12) {
PipePluggable existing = tile.getPluggable(realSide);
if (existing != null) {
return existing.onPluggableActivate(player, trace, hitX, hitY, hitZ);
}
}
EnumPipePart part = trace.subHit == 0 ? EnumPipePart.CENTER : EnumPipePart.fromFacing(realSide);
ItemStack held = player.getHeldItem(hand);
Item item = held.isEmpty() ? null : held.getItem();
PipePluggable existing = tile.getPluggable(realSide);
if (item instanceof IItemPluggable && existing == null) {
IItemPluggable itemPlug = (IItemPluggable) item;
PipePluggable plug = itemPlug.onPlace(held, tile, realSide, player, hand);
if (plug == null) {
return false;
} else {
tile.replacePluggable(realSide, plug);
if (!player.capabilities.isCreativeMode) {
held.shrink(1);
}
return true;
}
}
if (item instanceof ItemWire) {
EnumWirePart wirePartHit = getWirePartHit(trace);
EnumWirePart wirePart;
TilePipeHolder attachTile = tile;
if (wirePartHit != null) {
WireNode node = new WireNode(pos, wirePartHit);
node = node.offset(trace.sideHit);
wirePart = node.part;
if (!node.pos.equals(pos)) {
attachTile = getPipe(world, node.pos, false);
}
} else {
wirePart = EnumWirePart.get((trace.hitVec.x % 1 + 1) % 1 > 0.5, (trace.hitVec.y % 1 + 1) % 1 > 0.5, (trace.hitVec.z % 1 + 1) % 1 > 0.5);
}
if (wirePart != null && attachTile != null) {
boolean attached = attachTile.getWireManager().addPart(wirePart, EnumDyeColor.byMetadata(held.getMetadata()));
attachTile.scheduleNetworkUpdate(IPipeHolder.PipeMessageReceiver.WIRES);
if (attached && !player.capabilities.isCreativeMode) {
held.shrink(1);
}
if (attached) {
return true;
}
}
}
Pipe pipe = tile.getPipe();
if (pipe == null) {
return false;
}
if (pipe.behaviour.onPipeActivate(player, trace, hitX, hitY, hitZ, part)) {
return true;
}
if (pipe.flow.onFlowActivate(player, trace, hitX, hitY, hitZ, part)) {
return true;
}
return false;
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeTransportFluids method computeCurrentConnectionStatesAndTickFlows.
private int computeCurrentConnectionStatesAndTickFlows(short newTimeSlot) {
int outputCount = 0;
int fluidAmount = 0;
// Processes all internal tanks
for (EnumPipePart direction : EnumPipePart.values()) {
int dirI = direction.ordinal();
PipeSection section = sections[dirI];
fluidAmount += section.amount;
section.setTime(newTimeSlot);
section.moveFluids();
// Input processing
if (direction == EnumPipePart.CENTER) {
continue;
}
if (transferState[dirI] == TransferState.Input) {
inputTTL[dirI]--;
if (inputTTL[dirI] <= 0) {
transferState[dirI] = TransferState.None;
}
continue;
}
if (!container.pipe.outputOpen(direction.face)) {
transferState[dirI] = TransferState.None;
continue;
}
if (outputCooldown[dirI] > 0) {
outputCooldown[dirI]--;
continue;
}
if (outputTTL[dirI] <= 0) {
transferState[dirI] = TransferState.None;
outputCooldown[dirI] = OUTPUT_COOLDOWN;
outputTTL[dirI] = OUTPUT_TTL;
continue;
}
if (canReceiveCache[dirI] && container.pipe.outputOpen(direction.face)) {
transferState[dirI] = TransferState.Output;
outputCount++;
}
}
if (fluidAmount == 0) {
setFluidType(null);
}
return outputCount;
}
Aggregations