Search in sources :

Example 21 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleCrafter method importFromCraftingTable.

public void importFromCraftingTable(@Nullable EntityPlayer player) {
    if (MainProxy.isClient(getWorld())) {
        // Send packet asking for import
        final CoordinatesPacket packet = PacketHandler.getPacket(CPipeSatelliteImport.class).setModulePos(this);
        MainProxy.sendPacketToServer(packet);
    } else {
        final IPipeServiceProvider service = _service;
        if (service == null)
            return;
        service.getAvailableAdjacent().neighbors().keySet().stream().flatMap(neighbor -> SimpleServiceLocator.craftingRecipeProviders.stream().filter(provider -> provider.importRecipe(neighbor.getTileEntity(), dummyInventory)).map(provider1 -> new Pair<>(neighbor, provider1))).findFirst().ifPresent(neighborProviderPair -> {
            if (neighborProviderPair.getValue2() instanceof IFuzzyRecipeProvider) {
                ((IFuzzyRecipeProvider) neighborProviderPair.getValue2()).importFuzzyFlags(neighborProviderPair.getValue1().getTileEntity(), dummyInventory.getSlotAccess(), fuzzyFlags);
            }
        });
        // Send inventory as packet
        final CoordinatesPacket packet = PacketHandler.getPacket(CPipeSatelliteImportBack.class).setInventory(dummyInventory).setModulePos(this);
        if (player != null) {
            MainProxy.sendPacketToPlayer(packet, player);
        }
        MainProxy.sendPacketToAllWatchingChunk(this, packet);
    }
}
Also used : CPipeSatelliteImportBack(logisticspipes.network.packets.cpipe.CPipeSatelliteImportBack) ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) BitSetProperty(network.rs485.logisticspipes.property.BitSetProperty) Constants(net.minecraftforge.common.util.Constants) EnumHand(net.minecraft.util.EnumHand) MainProxy(logisticspipes.proxy.MainProxy) FluidCraftingAmount(logisticspipes.network.packets.pipe.FluidCraftingAmount) SinkReply(logisticspipes.utils.SinkReply) HUDStopModuleWatchingPacket(logisticspipes.network.packets.hud.HUDStopModuleWatchingPacket) ItemCraftingTemplate(logisticspipes.request.ItemCraftingTemplate) Map(java.util.Map) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) NewGuiHandler(logisticspipes.network.NewGuiHandler) LogisticsExtraPromise(logisticspipes.routing.LogisticsExtraPromise) LogisticsManager(logisticspipes.logistics.LogisticsManager) PacketHandler(logisticspipes.network.PacketHandler) ExitRoute(logisticspipes.routing.ExitRoute) UUIDPropertyKt(network.rs485.logisticspipes.property.UUIDPropertyKt) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) BooleanProperty(network.rs485.logisticspipes.property.BooleanProperty) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) BufferMode(logisticspipes.utils.SinkReply.BufferMode) CraftingModuleInHand(logisticspipes.network.guis.module.inhand.CraftingModuleInHand) IItemIdentifierInventory(network.rs485.logisticspipes.inventory.IItemIdentifierInventory) UUIDListProperty(network.rs485.logisticspipes.property.UUIDListProperty) CraftingPipeOpenConnectedGuiPacket(logisticspipes.network.packets.cpipe.CraftingPipeOpenConnectedGuiPacket) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) CraftingModuleSlot(logisticspipes.network.guis.module.inpipe.CraftingModuleSlot) InventoryProperty(network.rs485.logisticspipes.property.InventoryProperty) IWorldProvider(logisticspipes.interfaces.IWorldProvider) LogisticsDictPromise(logisticspipes.routing.LogisticsDictPromise) FuzzyUtil(network.rs485.logisticspipes.util.FuzzyUtil) Nullable(javax.annotation.Nullable) LogisticsItemOrder(logisticspipes.routing.order.LogisticsItemOrder) BlockPos(net.minecraft.util.math.BlockPos) LogisticsExtraDictPromise(logisticspipes.routing.LogisticsExtraDictPromise) DelayedGeneric(logisticspipes.utils.DelayedGeneric) ItemSendMode(logisticspipes.pipes.basic.CoreRoutedPipe.ItemSendMode) CPipeSatelliteImport(logisticspipes.network.packets.cpipe.CPipeSatelliteImport) HUDStartModuleWatchingPacket(logisticspipes.network.packets.hud.HUDStartModuleWatchingPacket) IResource(logisticspipes.request.resources.IResource) IBlockState(net.minecraft.block.state.IBlockState) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) TileEntity(net.minecraft.tileentity.TileEntity) ItemBlock(net.minecraft.item.ItemBlock) IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) ModuleInHandGuiProvider(logisticspipes.network.abstractguis.ModuleInHandGuiProvider) PipeItemsSatelliteLogistics(logisticspipes.pipes.PipeItemsSatelliteLogistics) IRouter(logisticspipes.routing.IRouter) IRequestFluid(logisticspipes.interfaces.routing.IRequestFluid) ItemUpgrade(logisticspipes.items.ItemUpgrade) ICraftingTemplate(logisticspipes.request.ICraftingTemplate) LogisticsPipes(logisticspipes.LogisticsPipes) Particles(logisticspipes.pipefxhandlers.Particles) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) DictCraftingTemplate(logisticspipes.request.DictCraftingTemplate) NBTTagList(net.minecraft.nbt.NBTTagList) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ICraftItems(logisticspipes.interfaces.routing.ICraftItems) LPNeighborTileEntityKt(network.rs485.logisticspipes.connection.LPNeighborTileEntityKt) IAdditionalTargetInformation(logisticspipes.interfaces.routing.IAdditionalTargetInformation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) Collection(java.util.Collection) FluidResource(logisticspipes.request.resources.FluidResource) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) IFuzzyRecipeProvider(logisticspipes.proxy.interfaces.IFuzzyRecipeProvider) UUID(java.util.UUID) RequestTreeNode(logisticspipes.request.RequestTreeNode) DictResource(logisticspipes.request.resources.DictResource) TransportMode(logisticspipes.logisticspipes.IRoutedItem.TransportMode) Objects(java.util.Objects) IItemSpaceControl(logisticspipes.interfaces.routing.IItemSpaceControl) List(java.util.List) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) CacheTypes(logisticspipes.utils.CacheHolder.CacheTypes) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) IHUDModuleHandler(logisticspipes.interfaces.IHUDModuleHandler) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Gui(network.rs485.logisticspipes.module.Gui) Property(network.rs485.logisticspipes.property.Property) IPromise(logisticspipes.request.IPromise) AdjacentUtilKt(network.rs485.logisticspipes.connection.AdjacentUtilKt) ItemResource(logisticspipes.request.resources.ItemResource) Getter(lombok.Getter) ModuleCoordinatesGuiProvider(logisticspipes.network.abstractguis.ModuleCoordinatesGuiProvider) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) IReqCraftingTemplate(logisticspipes.request.IReqCraftingTemplate) ResourceType(logisticspipes.routing.order.IOrderInfoProvider.ResourceType) CoordinatesPacket(logisticspipes.network.abstractpackets.CoordinatesPacket) IBitSet(network.rs485.logisticspipes.property.IBitSet) IntListProperty(network.rs485.logisticspipes.property.IntListProperty) IntegerProperty(network.rs485.logisticspipes.property.IntegerProperty) ImmutableList(com.google.common.collect.ImmutableList) IRequestItems(logisticspipes.interfaces.routing.IRequestItems) IModuleWatchReciver(logisticspipes.interfaces.IModuleWatchReciver) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager) DelayQueue(java.util.concurrent.DelayQueue) WeakReference(java.lang.ref.WeakReference) PipeFluidSatellite(logisticspipes.pipes.PipeFluidSatellite) Nonnull(javax.annotation.Nonnull) IHUDModuleRenderer(logisticspipes.interfaces.IHUDModuleRenderer) IGuiOpenControler(logisticspipes.interfaces.IGuiOpenControler) FixedPriority(logisticspipes.utils.SinkReply.FixedPriority) CraftingPipeUpdatePacket(logisticspipes.network.packets.pipe.CraftingPipeUpdatePacket) EnumFacing(net.minecraft.util.EnumFacing) LogisticsPromise(logisticspipes.routing.LogisticsPromise) RequestTree(logisticspipes.request.RequestTree) UUIDProperty(network.rs485.logisticspipes.property.UUIDProperty) BitSet(java.util.BitSet) IFuzzyRecipeProvider(logisticspipes.proxy.interfaces.IFuzzyRecipeProvider) CPipeSatelliteImport(logisticspipes.network.packets.cpipe.CPipeSatelliteImport) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) CoordinatesPacket(logisticspipes.network.abstractpackets.CoordinatesPacket) Pair(logisticspipes.utils.tuples.Pair)

Example 22 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleCrafter method extractFromInventoryFiltered.

@Nonnull
private ItemStack extractFromInventoryFiltered(@Nonnull IInventoryUtil invUtil, IItemIdentifierInventory filter, boolean isExcluded, int filterInvLimit) {
    final IPipeServiceProvider service = _service;
    if (service == null)
        return ItemStack.EMPTY;
    ItemIdentifier wanteditem = null;
    boolean found = false;
    for (ItemIdentifier item : invUtil.getItemsAndCount().keySet()) {
        found = isFiltered(filter, filterInvLimit, item, found);
        if (isExcluded != found) {
            wanteditem = item;
            break;
        }
    }
    if (wanteditem == null) {
        return ItemStack.EMPTY;
    }
    int available = invUtil.itemCount(wanteditem);
    if (available == 0 || !service.canUseEnergy(neededEnergy() * Math.min(64, available))) {
        return ItemStack.EMPTY;
    }
    ItemStack extracted = invUtil.getMultipleItems(wanteditem, Math.min(64, available));
    service.useEnergy(neededEnergy() * extracted.getCount());
    return extracted;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 23 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleSatellite method spaceFor.

private int spaceFor(@Nonnull ItemStack stack, ItemIdentifier item, boolean includeInTransit) {
    final IPipeServiceProvider service = Objects.requireNonNull(_service);
    int count = service.getAvailableAdjacent().inventories().stream().map(neighbor -> LPNeighborTileEntityKt.sneakyInsertion(neighbor).from(getUpgradeManager())).map(LPNeighborTileEntityKt::getInventoryUtil).filter(Objects::nonNull).map(util -> util.roomForItem(stack)).reduce(Integer::sum).orElse(0);
    if (includeInTransit) {
        count -= service.countOnRoute(item);
    }
    return count;
}
Also used : Objects(java.util.Objects) ItemStack(net.minecraft.item.ItemStack) SinkReply(logisticspipes.utils.SinkReply) List(java.util.List) FixedPriority(logisticspipes.utils.SinkReply.FixedPriority) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) LPNeighborTileEntityKt(network.rs485.logisticspipes.connection.LPNeighborTileEntityKt) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) Property(network.rs485.logisticspipes.property.Property) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Nonnull(javax.annotation.Nonnull) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) LPNeighborTileEntityKt(network.rs485.logisticspipes.connection.LPNeighborTileEntityKt)

Example 24 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleActiveSupplier method itemArrived.

@Override
public void itemArrived(ItemIdentifierStack item, IAdditionalTargetInformation info) {
    final IPipeServiceProvider service = Objects.requireNonNull(_service);
    service.getDebug().log("Supplier: Registered Item Arrived: " + item);
    decreaseRequested(item);
}
Also used : IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider)

Example 25 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleActiveSupplier method tick.

@Override
public void tick() {
    final IPipeServiceProvider service = Objects.requireNonNull(_service);
    if (!service.isNthTick(100)) {
        return;
    }
    _requestedItems.values().stream().filter(amount -> amount > 0).forEach(amount -> service.spawnParticle(Particles.VioletParticle, 2));
    AdjacentUtilKt.sneakyInventoryUtils(service.getAvailableAdjacent(), getUpgradeManager()).stream().filter(invUtil -> invUtil != null && invUtil.getSizeInventory() > 0).forEach(invUtil -> {
        if (getUpgradeManager().hasPatternUpgrade()) {
            createPatternRequest(invUtil);
        } else {
            createSupplyRequest(invUtil);
        }
    });
}
Also used : ModuleInHandGuiProvider(logisticspipes.network.abstractguis.ModuleInHandGuiProvider) ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) IRouter(logisticspipes.routing.IRouter) Particles(logisticspipes.pipefxhandlers.Particles) ActiveSupplierInHand(logisticspipes.network.guis.module.inhand.ActiveSupplierInHand) MainProxy(logisticspipes.proxy.MainProxy) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) IRequireReliableTransport(logisticspipes.interfaces.routing.IRequireReliableTransport) HUDStopModuleWatchingPacket(logisticspipes.network.packets.hud.HUDStopModuleWatchingPacket) Map(java.util.Map) ITargetSlotInformation(logisticspipes.interfaces.routing.ITargetSlotInformation) IAdditionalTargetInformation(logisticspipes.interfaces.routing.IAdditionalTargetInformation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NewGuiHandler(logisticspipes.network.NewGuiHandler) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) IModuleInventoryReceive(logisticspipes.interfaces.IModuleInventoryReceive) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BooleanProperty(network.rs485.logisticspipes.property.BooleanProperty) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) IHUDModuleHandler(logisticspipes.interfaces.IHUDModuleHandler) Gui(network.rs485.logisticspipes.module.Gui) EnumProperty(network.rs485.logisticspipes.property.EnumProperty) Property(network.rs485.logisticspipes.property.Property) NotNull(org.jetbrains.annotations.NotNull) IntStream(java.util.stream.IntStream) AdjacentUtilKt(network.rs485.logisticspipes.connection.AdjacentUtilKt) ModuleCoordinatesGuiProvider(logisticspipes.network.abstractguis.ModuleCoordinatesGuiProvider) HashMap(java.util.HashMap) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) ArrayList(java.util.ArrayList) IntListProperty(network.rs485.logisticspipes.property.IntListProperty) ItemStack(net.minecraft.item.ItemStack) IClientInformationProvider(logisticspipes.interfaces.IClientInformationProvider) StatusEntry(logisticspipes.pipes.basic.debug.StatusEntry) InventoryProperty(network.rs485.logisticspipes.property.InventoryProperty) ImmutableList(com.google.common.collect.ImmutableList) IRequestItems(logisticspipes.interfaces.routing.IRequestItems) IModuleWatchReciver(logisticspipes.interfaces.IModuleWatchReciver) Nonnull(javax.annotation.Nonnull) ActiveSupplierSlot(logisticspipes.network.guis.module.inpipe.ActiveSupplierSlot) Iterator(java.util.Iterator) IHUDModuleRenderer(logisticspipes.interfaces.IHUDModuleRenderer) RequestTree(logisticspipes.request.RequestTree) HUDStartModuleWatchingPacket(logisticspipes.network.packets.hud.HUDStartModuleWatchingPacket) ISimpleInventoryEventHandler(logisticspipes.utils.ISimpleInventoryEventHandler) ModuleInventory(logisticspipes.network.packets.module.ModuleInventory) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) IInventory(net.minecraft.inventory.IInventory) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider)

Aggregations

IPipeServiceProvider (logisticspipes.interfaces.IPipeServiceProvider)27 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)14 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)14 ItemStack (net.minecraft.item.ItemStack)13 Nonnull (javax.annotation.Nonnull)11 SinkReply (logisticspipes.utils.SinkReply)10 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)9 DictResource (logisticspipes.request.resources.DictResource)9 List (java.util.List)8 Objects (java.util.Objects)8 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)8 ISlotUpgradeManager (logisticspipes.interfaces.ISlotUpgradeManager)8 LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)8 Pair (logisticspipes.utils.tuples.Pair)8 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 ItemResource (logisticspipes.request.resources.ItemResource)7 Property (network.rs485.logisticspipes.property.Property)7 ImmutableList (com.google.common.collect.ImmutableList)6 Map (java.util.Map)6