Search in sources :

Example 21 with EnumPipePart

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;
            }
        }
    }
}
Also used : PacketBufferBC(buildcraft.lib.net.PacketBufferBC) EnumPipePart(buildcraft.api.core.EnumPipePart)

Example 22 with EnumPipePart

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;
}
Also used : IAction(buildcraft.api.statements.IAction) EnumPipePart(buildcraft.api.core.EnumPipePart) IStatement(buildcraft.api.statements.IStatement)

Example 23 with EnumPipePart

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;
}
Also used : EnumPipePart(buildcraft.api.core.EnumPipePart) IStatement(buildcraft.api.statements.IStatement) ITrigger(buildcraft.api.statements.ITrigger)

Example 24 with EnumPipePart

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;
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) EnumPipePart(buildcraft.api.core.EnumPipePart)

Aggregations

EnumPipePart (buildcraft.api.core.EnumPipePart)24 IStatement (buildcraft.api.statements.IStatement)6 PacketBufferBC (buildcraft.lib.net.PacketBufferBC)3 StatementWrapper (buildcraft.lib.statement.StatementWrapper)3 ArrayList (java.util.ArrayList)3 InvalidInputDataException (buildcraft.api.core.InvalidInputDataException)2 ISprite (buildcraft.api.core.render.ISprite)2 IAction (buildcraft.api.statements.IAction)2 IStatementParameter (buildcraft.api.statements.IStatementParameter)2 ITrigger (buildcraft.api.statements.ITrigger)2 GuiIcon (buildcraft.lib.gui.GuiIcon)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 ITriggerExternalOverride (buildcraft.api.statements.ITriggerExternalOverride)1 StatementManager (buildcraft.api.statements.StatementManager)1 EnumWirePart (buildcraft.api.transport.EnumWirePart)1 IItemPluggable (buildcraft.api.transport.IItemPluggable)1 IStripesHandler (buildcraft.api.transport.IStripesHandler)1 WireNode (buildcraft.api.transport.WireNode)1 PipeEventFluid (buildcraft.api.transport.pipe.PipeEventFluid)1 OnMoveToCentre (buildcraft.api.transport.pipe.PipeEventFluid.OnMoveToCentre)1