use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class PipeFlowFluids method writePayload.
@Override
public void writePayload(int id, PacketBuffer buf, Side side) {
PacketBufferBC buffer = PacketBufferBC.asPacketBufferBc(buf);
if (side == Side.SERVER) {
if (id == NET_FLUID_AMOUNTS || id == NET_ID_FULL_STATE) {
boolean full = id == NET_ID_FULL_STATE;
if (currentFluid == null) {
buffer.writeBoolean(false);
} else {
buffer.writeBoolean(true);
buffer.writeInt(BuildCraftObjectCaches.CACHE_FLUIDS.server().store(currentFluid));
}
for (EnumPipePart part : EnumPipePart.VALUES) {
Section section = sections.get(part);
if (full) {
buffer.writeShort(section.amount);
} else if (section.amount == section.lastSentAmount) {
buffer.writeBoolean(false);
} else {
buffer.writeBoolean(true);
buffer.writeShort(section.amount);
section.lastSentAmount = section.amount;
}
Dir should = Dir.get(section.ticksInDirection);
// This writes out 2 bits so don't bother with a boolean flag
buffer.writeEnumValue(should);
section.lastSentDirection = should;
}
}
}
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class ActionType method readFromNbt.
@Override
public ActionWrapper readFromNbt(NBTTagCompound nbt) {
if (nbt == null) {
return null;
}
String kind = nbt.getString("kind");
if (kind == null || kind.isEmpty()) {
return null;
}
EnumPipePart side = EnumPipePart.fromMeta(nbt.getByte("side"));
IStatement statement = StatementManager.statements.get(kind);
if (statement instanceof IAction) {
return ActionWrapper.wrap(statement, side.face);
}
BCLog.logger.warn("[gate.trigger] Couldn't find an action called '{}'! (found {})", kind, statement);
return null;
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class TriggerType method readFromNbt.
@Override
public TriggerWrapper readFromNbt(NBTTagCompound nbt) {
if (nbt == null) {
return null;
}
String kind = nbt.getString("kind");
if (kind == null || kind.isEmpty()) {
return null;
}
EnumPipePart side = EnumPipePart.fromMeta(nbt.getByte("side"));
IStatement statement = StatementManager.statements.get(kind);
if (statement instanceof ITrigger) {
return TriggerWrapper.wrap(statement, side.face);
}
BCLog.logger.warn("[gate.trigger] Couldn't find a trigger called '{}'! (found {})", kind, statement);
return null;
}
use of buildcraft.api.core.EnumPipePart in project BuildCraft by BuildCraft.
the class ItemHandlerManager method addInvHandler.
public <T extends INBTSerializable<NBTTagCompound> & IItemHandlerModifiable> T addInvHandler(String key, T handler, EnumAccess access, EnumPipePart... parts) {
if (parts == null) {
parts = new EnumPipePart[0];
}
IItemHandlerModifiable external = handler;
if (access == EnumAccess.NONE || access == EnumAccess.PHANTOM) {
external = null;
if (parts.length > 0) {
throw new IllegalArgumentException("Completely useless to not allow access to multiple sides! Just don't pass any sides!");
}
} else if (access == EnumAccess.EXTRACT) {
external = new WrappedItemHandlerExtract(handler);
} else if (access == EnumAccess.INSERT) {
external = new WrappedItemHandlerInsert(handler);
}
if (external != null) {
Set<EnumPipePart> visited = EnumSet.noneOf(EnumPipePart.class);
for (EnumPipePart part : parts) {
if (part == null)
part = EnumPipePart.CENTER;
if (visited.add(part)) {
Wrapper wrapper = wrappers.get(part);
wrapper.handlers.add(external);
wrapper.genWrapper();
}
}
}
if (access != EnumAccess.PHANTOM) {
handlersToDrop.add(handler);
}
handlers.put(key, handler);
return handler;
}
Aggregations