Search in sources :

Example 16 with Pair

use of logisticspipes.utils.tuples.Pair 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 (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        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, Integer> result = SimpleServiceLocator.logisticsFluidManager.getBestReply(stack, getRouter(), tempJamList);
        if (result == null || result.getValue1() == null || result.getValue1() == 0 || result.getValue2() == 0) {
            nextSendMax[dir.ordinal()] = 100;
            nextSendMin[dir.ordinal()] = 10;
            continue;
        }
        if (!useEnergy((int) (0.01 * result.getValue2()))) {
            nextSendMax[dir.ordinal()] = 100;
            nextSendMin[dir.ordinal()] = 10;
            continue;
        }
        FluidStack toSend = transport.sideTanks[dir.ordinal()].drain(result.getValue2(), true);
        ItemIdentifierStack liquidContainer = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(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 : IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) Pair(logisticspipes.utils.tuples.Pair)

Example 17 with Pair

use of logisticspipes.utils.tuples.Pair in project LogisticsPipes by RS485.

the class PipeFluidSupplierMk2 method throttledUpdateEntity.

@Override
public void throttledUpdateEntity() {
    if (!isEnabled()) {
        return;
    }
    if (MainProxy.isClient(container.getWorld())) {
        return;
    }
    super.throttledUpdateEntity();
    if (dummyInventory.getStackInSlot(0) == null) {
        return;
    }
    WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(container);
    //@formatter:off
    worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IFluidHandler).filter(adjacent -> SimpleServiceLocator.pipeInformationManager.isItemPipe(adjacent.tileEntity)).map(adjacent -> new Pair<>((IFluidHandler) adjacent.tileEntity, adjacent.direction)).forEach(fluidHandlerDirectionPair -> {
        FluidTankInfo[] tankInfo = fluidHandlerDirectionPair.getValue1().getTankInfo(ForgeDirection.UNKNOWN);
        if (tankInfo == null || tankInfo.length == 0) {
            return;
        }
        Map<FluidIdentifier, Integer> wantFluids = new HashMap<>();
        FluidIdentifier fIdent = FluidIdentifier.get(dummyInventory.getIDStackInSlot(0).getItem());
        wantFluids.put(fIdent, amount);
        HashMap<FluidIdentifier, Integer> haveFluids = new HashMap<>();
        FluidTankInfo[] result = container.getTankInfo(ForgeDirection.UNKNOWN);
        for (FluidTankInfo slot : result) {
            if (slot == null || slot.fluid == null || slot.fluid.getFluidID() == 0 || !wantFluids.containsKey(FluidIdentifier.get(slot.fluid))) {
                continue;
            }
            Integer liquidWant = haveFluids.get(FluidIdentifier.get(slot.fluid));
            if (liquidWant == null) {
                haveFluids.put(FluidIdentifier.get(slot.fluid), slot.fluid.amount);
            } else {
                haveFluids.put(FluidIdentifier.get(slot.fluid), liquidWant + slot.fluid.amount);
            }
        }
        if (fluidHandlerDirectionPair.getValue2().ordinal() < ((PipeFluidTransportLogistics) transport).sideTanks.length) {
            FluidTank centerTank = ((PipeFluidTransportLogistics) transport).sideTanks[fluidHandlerDirectionPair.getValue2().ordinal()];
            if (centerTank != null && centerTank.getFluid() != null && wantFluids.containsKey(FluidIdentifier.get(centerTank.getFluid()))) {
                Integer liquidWant = haveFluids.get(FluidIdentifier.get(centerTank.getFluid()));
                if (liquidWant == null) {
                    haveFluids.put(FluidIdentifier.get(centerTank.getFluid()), centerTank.getFluid().amount);
                } else {
                    haveFluids.put(FluidIdentifier.get(centerTank.getFluid()), liquidWant + centerTank.getFluid().amount);
                }
            }
        }
        FluidTank centerTank = ((PipeFluidTransportLogistics) transport).internalTank;
        if (centerTank != null && centerTank.getFluid() != null && wantFluids.containsKey(FluidIdentifier.get(centerTank.getFluid()))) {
            Integer liquidWant = haveFluids.get(FluidIdentifier.get(centerTank.getFluid()));
            if (liquidWant == null) {
                haveFluids.put(FluidIdentifier.get(centerTank.getFluid()), centerTank.getFluid().amount);
            } else {
                haveFluids.put(FluidIdentifier.get(centerTank.getFluid()), liquidWant + centerTank.getFluid().amount);
            }
        }
        for (Entry<FluidIdentifier, Integer> liquidId : wantFluids.entrySet()) {
            Integer haveCount = haveFluids.get(liquidId.getKey());
            if (haveCount != null) {
                liquidId.setValue(liquidId.getValue() - haveCount);
            }
            _requestedItems.entrySet().stream().filter(requestedItem -> requestedItem.getKey().equals(liquidId.getKey())).forEach(requestedItem -> liquidId.setValue(liquidId.getValue() - requestedItem.getValue()));
        }
        setRequestFailed(false);
        for (FluidIdentifier need : wantFluids.keySet()) {
            int countToRequest = wantFluids.get(need);
            if (countToRequest < 1) {
                continue;
            }
            if (_bucketMinimum.getAmount() != 0 && countToRequest < _bucketMinimum.getAmount()) {
                continue;
            }
            if (!useEnergy(11)) {
                break;
            }
            boolean success = false;
            if (_requestPartials) {
                countToRequest = RequestTree.requestFluidPartial(need, countToRequest, this, null);
                if (countToRequest > 0) {
                    success = true;
                }
            } else {
                success = RequestTree.requestFluid(need, countToRequest, this, null);
            }
            if (success) {
                Integer currentRequest = _requestedItems.get(need);
                if (currentRequest == null) {
                    _requestedItems.put(need, countToRequest);
                } else {
                    _requestedItems.put(need, currentRequest + countToRequest);
                }
            } else {
                setRequestFailed(true);
            }
        }
    });
}
Also used : IRequireReliableFluidTransport(logisticspipes.interfaces.routing.IRequireReliableFluidTransport) Getter(lombok.Getter) IRequestFluid(logisticspipes.interfaces.routing.IRequestFluid) Textures(logisticspipes.textures.Textures) LogisticsPipes(logisticspipes.LogisticsPipes) Item(net.minecraft.item.Item) HashMap(java.util.HashMap) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) MainProxy(logisticspipes.proxy.MainProxy) FluidIdentifier(logisticspipes.utils.FluidIdentifier) Map(java.util.Map) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) TextureType(logisticspipes.textures.Textures.TextureType) PacketHandler(logisticspipes.network.PacketHandler) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) RequestTree(logisticspipes.request.RequestTree) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) FluidSupplierAmount(logisticspipes.network.packets.pipe.FluidSupplierAmount) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) IInventory(net.minecraft.inventory.IInventory) Entry(java.util.Map.Entry) FluidTank(net.minecraftforge.fluids.FluidTank) GuiIDs(logisticspipes.network.GuiIDs) FluidRoutedPipe(logisticspipes.pipes.basic.fluid.FluidRoutedPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) HashMap(java.util.HashMap) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) FluidIdentifier(logisticspipes.utils.FluidIdentifier) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) FluidTank(net.minecraftforge.fluids.FluidTank) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Pair(logisticspipes.utils.tuples.Pair)

Example 18 with Pair

use of logisticspipes.utils.tuples.Pair in project LogisticsPipes by RS485.

the class PipeItemsBasicLogistics method getPointedInventory.

@Override
public IInventoryUtil getPointedInventory(boolean forExtraction) {
    IInventoryUtil inv = super.getPointedInventory(forExtraction);
    if (inv == null) {
        Optional<Pair<IInventory, ForgeDirection>> first = new WorldCoordinatesWrapper(container).getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).map(adjacentInventory -> new Pair<>(InventoryHelper.getInventory((IInventory) adjacentInventory.tileEntity), adjacentInventory.direction)).filter(inventoryDirectionPair -> inventoryDirectionPair.getValue1() != null).findFirst();
        if (first.isPresent()) {
            Pair<IInventory, ForgeDirection> p = first.get();
            inv = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(p.getValue1(), p.getValue2().getOpposite());
        }
    }
    return inv;
}
Also used : OrientationsUtil(logisticspipes.utils.OrientationsUtil) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) TreeSet(java.util.TreeSet) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) InventoryHelper(logisticspipes.utils.InventoryHelper) ModulePositionType(logisticspipes.modules.abstractmodules.LogisticsModule.ModulePositionType) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) TextureType(logisticspipes.textures.Textures.TextureType) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ModuleItemSink(logisticspipes.modules.ModuleItemSink) Pair(logisticspipes.utils.tuples.Pair) IInventory(net.minecraft.inventory.IInventory) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) IInventory(net.minecraft.inventory.IInventory) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Pair(logisticspipes.utils.tuples.Pair)

Example 19 with Pair

use of logisticspipes.utils.tuples.Pair in project LogisticsPipes by RS485.

the class PowerSupplierHandler method update.

public void update() {
    if (SimpleServiceLocator.cofhPowerProxy.isAvailable() && pipe.getUpgradeManager().hasRFPowerSupplierUpgrade()) {
        //Use Buffer
        Stream<AdjacentTileEntity> adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        double globalNeed = 0;
        double[] need = new double[(int) adjacentTileEntityStream.count()];
        adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        int i = 0;
        Iterator<AdjacentTileEntity> adjacentIt = adjacentTileEntityStream.iterator();
        while (adjacentIt.hasNext()) {
            AdjacentTileEntity adjacent = adjacentIt.next();
            if (SimpleServiceLocator.cofhPowerProxy.isEnergyReceiver(adjacent.tileEntity)) {
                if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                    ICoFHEnergyReceiver energyReceiver = SimpleServiceLocator.cofhPowerProxy.getEnergyReceiver(adjacent.tileEntity);
                    ForgeDirection oppositeDir = adjacent.direction.getOpposite();
                    if (energyReceiver.canConnectEnergy(oppositeDir)) {
                        globalNeed += need[i] = (energyReceiver.getMaxEnergyStored(oppositeDir) - energyReceiver.getEnergyStored(oppositeDir));
                    }
                }
            }
            ++i;
        }
        if (globalNeed != 0 && !Double.isNaN(globalNeed)) {
            double fullfillable = Math.min(1, internalBufferRF / globalNeed);
            i = 0;
            adjacentIt = adjacentTileEntityStream.iterator();
            while (adjacentIt.hasNext()) {
                AdjacentTileEntity adjacent = adjacentIt.next();
                if (SimpleServiceLocator.cofhPowerProxy.isEnergyReceiver(adjacent.tileEntity)) {
                    if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                        ICoFHEnergyReceiver energyReceiver = SimpleServiceLocator.cofhPowerProxy.getEnergyReceiver(adjacent.tileEntity);
                        ForgeDirection oppositeDir = adjacent.direction.getOpposite();
                        if (energyReceiver.canConnectEnergy(oppositeDir)) {
                            if (internalBufferRF + 1 < need[i] * fullfillable) {
                                return;
                            }
                            int used = energyReceiver.receiveEnergy(oppositeDir, (int) (need[i] * fullfillable), false);
                            if (used > 0) {
                                pipe.container.addLaser(adjacent.direction, 0.5F, LogisticsPowerProviderTileEntity.RF_COLOR, false, true);
                                internalBufferRF -= used;
                            }
                            if (internalBufferRF < 0) {
                                internalBufferRF = 0;
                                return;
                            }
                        }
                    }
                }
                ++i;
            }
        }
        //Rerequest Buffer
        List<Pair<ISubSystemPowerProvider, List<IFilter>>> provider = pipe.getRouter().getSubSystemPowerProvider();
        double available = 0;
        outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
            for (IFilter filter : pair.getValue2()) {
                if (filter.blockPower()) {
                    continue outer;
                }
            }
            if (pair.getValue1().usePaused()) {
                continue;
            }
            if (!pair.getValue1().getBrand().equals("RF")) {
                continue;
            }
            available += pair.getValue1().getPowerLevel();
        }
        if (available > 0) {
            double neededPower = PowerSupplierHandler.INTERNAL_RF_BUFFER_MAX - internalBufferRF;
            if (neededPower > 0) {
                if (pipe.useEnergy((int) (neededPower / 100), false)) {
                    outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
                        for (IFilter filter : pair.getValue2()) {
                            if (filter.blockPower()) {
                                continue outer;
                            }
                        }
                        if (pair.getValue1().usePaused()) {
                            continue;
                        }
                        if (!pair.getValue1().getBrand().equals("RF")) {
                            continue;
                        }
                        double requestamount = neededPower * (pair.getValue1().getPowerLevel() / available);
                        pair.getValue1().requestPower(pipe.getRouterId(), requestamount);
                    }
                }
            }
        }
    }
    if (SimpleServiceLocator.IC2Proxy.hasIC2() && pipe.getUpgradeManager().getIC2PowerLevel() > 0) {
        //Use Buffer
        Stream<AdjacentTileEntity> adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        double globalNeed = 0;
        double[] need = new double[(int) adjacentTileEntityStream.count()];
        adjacentTileEntityStream = new WorldCoordinatesWrapper(pipe.container).getAdjacentTileEntities();
        int i = 0;
        Iterator<AdjacentTileEntity> adjacentIt = adjacentTileEntityStream.iterator();
        while (adjacentIt.hasNext()) {
            AdjacentTileEntity adjacent = adjacentIt.next();
            if (SimpleServiceLocator.IC2Proxy.isEnergySink(adjacent.tileEntity)) {
                if (pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction)) {
                    if (SimpleServiceLocator.IC2Proxy.acceptsEnergyFrom(adjacent.tileEntity, pipe.container, adjacent.direction.getOpposite())) {
                        globalNeed += need[i] = SimpleServiceLocator.IC2Proxy.demandedEnergyUnits(adjacent.tileEntity);
                    }
                }
            }
            ++i;
        }
        if (globalNeed != 0 && !Double.isNaN(globalNeed)) {
            double fullfillable = Math.min(1, internalBufferIC2 / globalNeed);
            i = 0;
            adjacentIt = adjacentTileEntityStream.iterator();
            while (adjacentIt.hasNext()) {
                AdjacentTileEntity adjacent = adjacentIt.next();
                if (SimpleServiceLocator.IC2Proxy.isEnergySink(adjacent.tileEntity) && pipe.canPipeConnect(adjacent.tileEntity, adjacent.direction) && SimpleServiceLocator.IC2Proxy.acceptsEnergyFrom(adjacent.tileEntity, pipe.container, adjacent.direction.getOpposite())) {
                    if (internalBufferIC2 + 1 < need[i] * fullfillable) {
                        return;
                    }
                    double toUse = Math.min(pipe.getUpgradeManager().getIC2PowerLevel(), need[i] * fullfillable);
                    double unUsed = SimpleServiceLocator.IC2Proxy.injectEnergyUnits(adjacent.tileEntity, adjacent.direction.getOpposite(), toUse);
                    double used = toUse - unUsed;
                    if (used > 0) {
                        //MainProxy.sendPacketToAllWatchingChunk(this.pipe.getX(), this.pipe.getZ(), MainProxy.getDimensionForWorld(this.pipe.getWorld()), PacketHandler.getPacket(PowerPacketLaser.class).setColor(LogisticsPowerProviderTileEntity.IC2_COLOR).setPos(this.pipe.getLPPosition()).setRenderBall(true).setDir(adTile.orientation).setLength(0.5F));
                        pipe.container.addLaser(adjacent.direction, 0.5F, LogisticsPowerProviderTileEntity.IC2_COLOR, false, true);
                        internalBufferIC2 -= used;
                    }
                    if (internalBufferIC2 < 0) {
                        internalBufferIC2 = 0;
                        return;
                    }
                }
                ++i;
            }
        }
        //Rerequest Buffer
        List<Pair<ISubSystemPowerProvider, List<IFilter>>> provider = pipe.getRouter().getSubSystemPowerProvider();
        double available = 0;
        outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
            for (IFilter filter : pair.getValue2()) {
                if (filter.blockPower()) {
                    continue outer;
                }
            }
            if (pair.getValue1().usePaused()) {
                continue;
            }
            if (!pair.getValue1().getBrand().equals("EU")) {
                continue;
            }
            available += pair.getValue1().getPowerLevel();
        }
        if (available > 0) {
            double neededPower = PowerSupplierHandler.INTERNAL_IC2_BUFFER_MAX - internalBufferIC2;
            if (neededPower > 0) {
                if (pipe.useEnergy((int) (neededPower / 10000), false)) {
                    outer: for (Pair<ISubSystemPowerProvider, List<IFilter>> pair : provider) {
                        for (IFilter filter : pair.getValue2()) {
                            if (filter.blockPower()) {
                                continue outer;
                            }
                        }
                        if (pair.getValue1().usePaused()) {
                            continue;
                        }
                        if (!pair.getValue1().getBrand().equals("EU")) {
                            continue;
                        }
                        double requestamount = neededPower * (pair.getValue1().getPowerLevel() / available);
                        pair.getValue1().requestPower(pipe.getRouterId(), requestamount);
                    }
                }
            }
        }
    }
}
Also used : IFilter(logisticspipes.interfaces.routing.IFilter) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) AdjacentTileEntity(network.rs485.logisticspipes.world.WorldCoordinatesWrapper.AdjacentTileEntity) ICoFHEnergyReceiver(logisticspipes.proxy.cofh.subproxies.ICoFHEnergyReceiver) Pair(logisticspipes.utils.tuples.Pair)

Example 20 with Pair

use of logisticspipes.utils.tuples.Pair in project LogisticsPipes by RS485.

the class FluidRoutedPipe method enabledUpdateEntity.

@Override
public void enabledUpdateEntity() {
    super.enabledUpdateEntity();
    if (canInsertFromSideToTanks()) {
        int validDirections = 0;
        List<Pair<TileEntity, ForgeDirection>> list = getAdjacentTanks(true);
        for (Pair<TileEntity, ForgeDirection> pair : list) {
            if (pair.getValue1() instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) pair.getValue1()).pipe instanceof CoreRoutedPipe) {
                    continue;
                }
            }
            FluidTank tank = ((PipeFluidTransportLogistics) transport).sideTanks[pair.getValue2().ordinal()];
            validDirections++;
            if (tank.getFluid() == null) {
                continue;
            }
            int filled = ((IFluidHandler) pair.getValue1()).fill(pair.getValue2().getOpposite(), tank.getFluid().copy(), true);
            if (filled == 0) {
                continue;
            }
            FluidStack drain = tank.drain(filled, true);
            if (drain == null || filled != drain.amount) {
                if (LPConstants.DEBUG) {
                    throw new UnsupportedOperationException("Fluid Multiplication");
                }
            }
        }
        if (validDirections == 0) {
            return;
        }
        FluidTank tank = ((PipeFluidTransportLogistics) transport).internalTank;
        FluidStack stack = tank.getFluid();
        if (stack == null) {
            return;
        }
        for (Pair<TileEntity, ForgeDirection> pair : list) {
            if (pair.getValue1() instanceof LogisticsTileGenericPipe) {
                if (((LogisticsTileGenericPipe) pair.getValue1()).pipe instanceof CoreRoutedPipe) {
                    continue;
                }
            }
            FluidTank tankSide = ((PipeFluidTransportLogistics) transport).sideTanks[pair.getValue2().ordinal()];
            stack = tank.getFluid();
            if (stack == null) {
                continue;
            }
            stack = stack.copy();
            int filled = tankSide.fill(stack, true);
            if (filled == 0) {
                continue;
            }
            FluidStack drain = tank.drain(filled, true);
            if (drain == null || filled != drain.amount) {
                if (LPConstants.DEBUG) {
                    throw new UnsupportedOperationException("Fluid Multiplication");
                }
            }
        }
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) TileEntity(net.minecraft.tileentity.TileEntity) FluidTank(net.minecraftforge.fluids.FluidTank) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

Pair (logisticspipes.utils.tuples.Pair)27 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)13 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)11 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)11 ArrayList (java.util.ArrayList)10 List (java.util.List)9 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)8 Map (java.util.Map)7 IFilter (logisticspipes.interfaces.routing.IFilter)7 ExitRoute (logisticspipes.routing.ExitRoute)7 ItemStack (net.minecraft.item.ItemStack)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 HashMap (java.util.HashMap)6 LinkedList (java.util.LinkedList)6 Entry (java.util.Map.Entry)6 MainProxy (logisticspipes.proxy.MainProxy)6 IRouter (logisticspipes.routing.IRouter)6 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)6 IInventory (net.minecraft.inventory.IInventory)6 TileEntity (net.minecraft.tileentity.TileEntity)6