Examples of IInventoryUtil


Examples of logisticspipes.interfaces.IInventoryUtil

    Set<ItemIdentifier> l1 = null;
    for (AdjacentTile tile : wUtil.getAdjacentTileEntities(true)){
      if (!(tile.tile instanceof IInventory)) continue;
      if (SimpleServiceLocator.pipeInformaitonManager.isPipe(tile.tile)) continue;
     
      IInventoryUtil inv = getAdaptedInventoryUtil(tile);
      Set<ItemIdentifier> items = inv.getItems();
      if(l1==null)
        l1=items;
      else
        l1.addAll(items);
    }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  public IInventoryUtil getInventoryUtil(IInventory inv, ForgeDirection dir) {
    return getHidingInventoryUtil(inv, dir, false, false, 0, 0);
  }

  public IInventoryUtil getHidingInventoryUtil(IInventory inv, ForgeDirection dir, boolean hideOnePerStack, boolean hideOne, int cropStart, int cropEnd) {
    IInventoryUtil util = getUtilForInv(inv, dir, hideOnePerStack, hideOne, cropStart, cropEnd);
    if (util == null) {
      util = new InventoryUtil(InventoryHelper.getInventory(inv), hideOnePerStack, hideOne, cropStart, cropEnd);;
    }
    return util;
  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

    ForgeDirection extractOrientation = _sneakyDirection;
    if(extractOrientation == ForgeDirection.UNKNOWN) {
      extractOrientation = _service.inventoryOrientation().getOpposite();
    }
    IInventoryUtil inventory = _service.getSneakyInventory(extractOrientation,true);
    if (inventory == null) return;

    checkExtract(inventory);
  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

    return getTotalItemCount(item) - _service.getOrderManager().totalItemsCountInOrders(item);
  }

  @Override
  public void getAllItems(Map<ItemIdentifier, Integer> items, List<IFilter> filters) {
    IInventoryUtil inv = _service.getPointedInventory(_extractionMode,true);
    if (inv == null) return;
   
    Map<ItemIdentifier, Integer> currentInv = inv.getItemsAndCount();

    //Skip already added items from this provider, skip filtered items, Reduce what has been reserved, add.
outer:
    for (Entry<ItemIdentifier, Integer> currItem : currentInv.entrySet()) {
      if(items.containsKey(currItem.getKey())) continue;
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

 
  // returns -1 on permanently failed, don't try another stack this tick
  // returns 0 on "unable to do this delivery"
  private int sendStack(ItemIdentifierStack stack, int maxCount, int destination, IAdditionalTargetInformation info) {
    ItemIdentifier item = stack.getItem();
    IInventoryUtil inv = _service.getPointedInventory(_extractionMode,true);
    if (inv == null) {
      _service.getOrderManager().sendFailed();
      return 0;
    }
   
    int available = inv.itemCount(item);
    if (available == 0) {
      _service.getOrderManager().sendFailed();
      return 0;
    }
    int wanted = Math.min(available, stack.getStackSize());
    wanted = Math.min(wanted, maxCount);
    wanted = Math.min(wanted, item.getMaxStackSize());
    IRouter dRtr = SimpleServiceLocator.routerManager.getRouterUnsafe(destination,false);
    if(dRtr == null) {
      _service.getOrderManager().sendFailed();
      return 0;
    }
    SinkReply reply = LogisticsManager.canSink(dRtr, null, true, stack.getItem(), null, true, false);
    boolean defersend = false;
    if(reply != null) {// some pipes are not aware of the space in the adjacent inventory, so they return null
      if(reply.maxNumberOfItems < wanted) {
        wanted = reply.maxNumberOfItems;
        if(wanted <= 0) {
          _service.getOrderManager().deferSend();
          return 0;
        }
        defersend = true;
      }
    }
    if(!_service.canUseEnergy(wanted * neededEnergy())) return -1;

    ItemStack removed = inv.getMultipleItems(item, wanted);
    if(removed == null || removed.stackSize == 0) {
      _service.getOrderManager().sendFailed();
      return 0;
    }
    int sent = removed.stackSize;
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

    return sent;
  }
 
  private int getTotalItemCount(ItemIdentifier item) {
   
    IInventoryUtil inv = _service.getPointedInventory(_extractionMode,true);
    if (inv == null) return 0;
   
    if(!filterAllowsItem(item)) return 0;
   
    return inv.itemCount(item);
  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  private static final SinkReply _sinkReply = new SinkReply(FixedPriority.ItemSink, 0, true, false, 3, 0);
  @Override
  public SinkReply sinksItem(ItemIdentifier item, int bestPriority, int bestCustomPriority, boolean allowDefault, boolean includeInTransit) {
    if(bestPriority > _sinkReply.fixedPriority.ordinal() || (bestPriority == _sinkReply.fixedPriority.ordinal() && bestCustomPriority >= _sinkReply.customPriority)) return null;
    IInventoryUtil targetInventory = _service.getSneakyInventory(false);
    if (targetInventory == null) return null;
   
    if (!targetInventory.containsUndamagedItem(item.getUndamaged())) return null;
   
    if(_service.canUseEnergy(3)) {
      return _sinkReply;
    }
    return null;
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

      if (!(tile.tile instanceof IInventory)) continue;
      IInventory base = (IInventory) tile.tile;
      if (base instanceof net.minecraft.inventory.ISidedInventory) {
        base = new SidedInventoryMinecraftAdapter((net.minecraft.inventory.ISidedInventory) base, tile.orientation.getOpposite(),false);
      }
      IInventoryUtil inv =SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(base);
      count += inv.roomForItem(item, 9999);
    }
    if(includeInTransit) {
      count -= pipe.countOnRoute(item);
    }
    return count;
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

      if(!(tile.tile instanceof IInventory)) continue;
      IInventory base = (IInventory)tile.tile;
      if(base instanceof net.minecraft.inventory.ISidedInventory) {
        base = new SidedInventoryMinecraftAdapter((net.minecraft.inventory.ISidedInventory)base, tile.orientation.getOpposite(), false);
      }
      IInventoryUtil inv = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(base);
      count += inv.roomForItem(item, 9999);
    }
    if(includeInTransit) {
      count -= _service.countOnRoute(item);
    }
    return count;
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

    }
    return null;
  }
 
  private ItemStack extractFromIInventory(IInventory inv, ItemIdentifier wanteditem, int count){
    IInventoryUtil invUtil = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv);
    int available = invUtil.itemCount(wanteditem);
    if(available == 0) return null;
    if(!_service.useEnergy(neededEnergy() * Math.min(count, available))) {
      return null;
    }
    return invUtil.getMultipleItems(wanteditem, Math.min(count, available));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.