Search in sources :

Example 31 with SinkReply

use of logisticspipes.utils.SinkReply in project LogisticsPipes by RS485.

the class ModuleApiaristAnalyser method registerPosition.

@Override
public void registerPosition(ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.APIARIST_Analyser, 0, true, false, 3, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassi.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 32 with SinkReply

use of logisticspipes.utils.SinkReply in project LogisticsPipes by RS485.

the class ModuleApiaristRefiller method tick.

@Override
public void tick() {
    if (++currentTickCount < ticksToOperation) {
        return;
    }
    currentTickCount = 0;
    IInventory inv = _service.getRealInventory();
    if (!(inv instanceof ISidedInventory)) {
        return;
    }
    ISidedInventory sinv = (ISidedInventory) inv;
    ForgeDirection direction = _service.inventoryOrientation().getOpposite();
    ItemStack stack = extractItem(sinv, false, direction, 1);
    if (stack == null) {
        return;
    }
    if (!(_service.canUseEnergy(100))) {
        return;
    }
    currentTickCount = ticksToOperation;
    if (reinsertBee(stack, sinv, direction)) {
        return;
    }
    Pair<Integer, SinkReply> reply = _service.hasDestination(ItemIdentifier.get(stack), true, new ArrayList<>());
    if (reply == null) {
        return;
    }
    _service.useEnergy(20);
    extractItem(sinv, true, direction, 1);
    _service.sendStack(stack, reply, ItemSendMode.Normal);
}
Also used : IInventory(net.minecraft.inventory.IInventory) ISidedInventory(net.minecraft.inventory.ISidedInventory) SinkReply(logisticspipes.utils.SinkReply) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack)

Example 33 with SinkReply

use of logisticspipes.utils.SinkReply in project LogisticsPipes by RS485.

the class ModuleApiaristSink method registerPosition.

@Override
public void registerPosition(ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.APIARIST_BeeSink, 0, true, false, 2, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassi.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 34 with SinkReply

use of logisticspipes.utils.SinkReply in project LogisticsPipes by RS485.

the class ModuleElectricBuffer method registerPosition.

@Override
public void registerPosition(ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.ElectricBuffer, 0, true, false, 1, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassi.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 35 with SinkReply

use of logisticspipes.utils.SinkReply in project LogisticsPipes by RS485.

the class ModuleElectricManager method tick.

@Override
public void tick() {
    if (++currentTick < ticksToAction) {
        return;
    }
    currentTick = 0;
    IInventoryUtil inv = _service.getSneakyInventory(true, slot, positionInt);
    if (inv == null) {
        return;
    }
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (stack == null) {
            return;
        }
        if (isOfInterest(stack)) {
            //If item set to discharge and its fully discharged, then extract it.
            if (_dischargeMode && SimpleServiceLocator.IC2Proxy.isFullyDischarged(stack)) {
                Triplet<Integer, SinkReply, List<IFilter>> reply = SimpleServiceLocator.logisticsManager.hasDestinationWithMinPriority(ItemIdentifier.get(stack), _service.getSourceID(), true, FixedPriority.ElectricBuffer);
                if (reply == null) {
                    continue;
                }
                if (_service.useEnergy(10)) {
                    _service.spawnParticle(Particles.OrangeParticle, 2);
                    _service.sendStack(inv.decrStackSize(i, 1), reply, ItemSendMode.Normal);
                    return;
                }
            }
            //If item set to charge  and its fully charged, then extract it.
            if (!_dischargeMode && SimpleServiceLocator.IC2Proxy.isFullyCharged(stack)) {
                Triplet<Integer, SinkReply, List<IFilter>> reply = SimpleServiceLocator.logisticsManager.hasDestinationWithMinPriority(ItemIdentifier.get(stack), _service.getSourceID(), true, FixedPriority.ElectricBuffer);
                if (reply == null) {
                    continue;
                }
                if (_service.useEnergy(10)) {
                    _service.spawnParticle(Particles.OrangeParticle, 2);
                    _service.sendStack(inv.decrStackSize(i, 1), reply, ItemSendMode.Normal);
                    return;
                }
            }
        }
    }
}
Also used : SinkReply(logisticspipes.utils.SinkReply) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SinkReply (logisticspipes.utils.SinkReply)36 ChassiTargetInformation (logisticspipes.pipes.PipeLogisticsChassi.ChassiTargetInformation)17 ItemStack (net.minecraft.item.ItemStack)10 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)9 LinkedList (java.util.LinkedList)7 List (java.util.List)6 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)6 ArrayList (java.util.ArrayList)5 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)4 IRouter (logisticspipes.routing.IRouter)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)3 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)3 ExitRoute (logisticspipes.routing.ExitRoute)3 LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)3 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)3 IInventory (net.minecraft.inventory.IInventory)3 BitSet (java.util.BitSet)2 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)2 IFilter (logisticspipes.interfaces.routing.IFilter)2