Search in sources :

Example 16 with IRoutedItem

use of logisticspipes.logisticspipes.IRoutedItem in project LogisticsPipes by RS485.

the class PipeBlockRequestTable method enabledUpdateEntity.

@Override
public void enabledUpdateEntity() {
    super.enabledUpdateEntity();
    ItemStack stack = toSortInv.getStackInSlot(0);
    if (!stack.isEmpty()) {
        if (delay > 0) {
            delay--;
            return;
        }
        IRoutedItem itemToSend = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
        SimpleServiceLocator.logisticsManager.assignDestinationFor(itemToSend, getRouter().getSimpleID(), false);
        if (itemToSend.getDestinationUUID() != null) {
            EnumFacing dir = getRouteLayer().getOrientationForItem(itemToSend, null);
            super.queueRoutedItem(itemToSend, dir.getOpposite());
            spawnParticle(Particles.OrangeParticle, 4);
            toSortInv.clearInventorySlotContents(0);
        } else {
            delay = 100;
        }
    } else {
        delay = 0;
    }
}
Also used : IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack)

Example 17 with IRoutedItem

use of logisticspipes.logisticspipes.IRoutedItem in project LogisticsPipes by RS485.

the class PipeFluidInsertion method enabledUpdateEntity.

@Override
public void enabledUpdateEntity() {
    super.enabledUpdateEntity();
    List<Integer> tempJamList = new ArrayList<>();
    if (!localJamList.isEmpty()) {
        List<Pair<Integer, Integer>> toRemove = new ArrayList<>();
        for (Pair<Integer, Integer> part : localJamList) {
            part.setValue2(part.getValue2() - 1);
            if (part.getValue2() <= 0) {
                toRemove.add(part);
            } else {
                tempJamList.add(part.getValue1());
            }
        }
        if (!toRemove.isEmpty()) {
            localJamList.removeAll(toRemove);
        }
    }
    PipeFluidTransportLogistics transport = (PipeFluidTransportLogistics) this.transport;
    for (EnumFacing dir : EnumFacing.VALUES) {
        FluidStack stack = transport.sideTanks[dir.ordinal()].getFluid();
        if (stack == null) {
            continue;
        }
        stack = stack.copy();
        if (nextSendMax[dir.ordinal()] > 0 && stack.amount < transport.sideTanks[dir.ordinal()].getCapacity()) {
            nextSendMax[dir.ordinal()]--;
            continue;
        }
        if (nextSendMin[dir.ordinal()] > 0) {
            nextSendMin[dir.ordinal()]--;
            continue;
        }
        Pair<Integer, FluidSinkReply> result = SimpleServiceLocator.logisticsFluidManager.getBestReply(FluidIdentifierStack.getFromStack(stack), getRouter(), tempJamList);
        if (result == null || result.getValue2().sinkAmount <= 0) {
            nextSendMax[dir.ordinal()] = 100;
            nextSendMin[dir.ordinal()] = 10;
            continue;
        }
        if (!useEnergy((int) (0.01 * result.getValue2().getSinkAmountInt()))) {
            nextSendMax[dir.ordinal()] = 100;
            nextSendMin[dir.ordinal()] = 10;
            continue;
        }
        FluidStack toSend = transport.sideTanks[dir.ordinal()].drain(result.getValue2().getSinkAmountInt(), true);
        ItemIdentifierStack liquidContainer = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(FluidIdentifierStack.getFromStack(toSend));
        IRoutedItem routed = SimpleServiceLocator.routedItemHelper.createNewTravelItem(liquidContainer);
        routed.setDestination(result.getValue1());
        routed.setTransportMode(TransportMode.Passive);
        this.queueRoutedItem(routed, dir);
        nextSendMax[dir.ordinal()] = 100;
        nextSendMin[dir.ordinal()] = 5;
    }
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) FluidSinkReply(logisticspipes.utils.FluidSinkReply) IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)17 EnumFacing (net.minecraft.util.EnumFacing)7 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)5 Pair (logisticspipes.utils.tuples.Pair)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)4 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)4 IFilter (logisticspipes.interfaces.routing.IFilter)4 Nonnull (javax.annotation.Nonnull)3 IRequestItems (logisticspipes.interfaces.routing.IRequestItems)3 LogisticsManager (logisticspipes.logistics.LogisticsManager)3 TransportMode (logisticspipes.logisticspipes.IRoutedItem.TransportMode)3 PacketHandler (logisticspipes.network.PacketHandler)3 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)3 RequestTree (logisticspipes.request.RequestTree)3 RequestTreeNode (logisticspipes.request.RequestTreeNode)3 ResourceType (logisticspipes.routing.order.IOrderInfoProvider.ResourceType)3