Examples of IInventoryUtil


Examples of logisticspipes.interfaces.IInventoryUtil

    }
    return invUtil.getMultipleItems(wanteditem, Math.min(count, available));
  }

  private ItemStack extractFromIInventoryFiltered(IInventory inv, ItemIdentifierInventory filter, boolean isExcluded, int filterInvLimit) {
    IInventoryUtil invUtil = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv);
    ItemIdentifier wanteditem = null;
    for(ItemIdentifier item:invUtil.getItemsAndCount().keySet()) {
      if(isExcluded) {
        boolean found = false;
        for(int i=0;i<filter.getSizeInventory() && i < filterInvLimit;i++) {
          ItemIdentifierStack identStack = filter.getIDStackInSlot(i);
          if(identStack == null) continue;
          if(identStack.getItem().equalsWithoutNBT(item)) {
            found = true;
            break;
          }
        }
        if(!found) {
          wanteditem = item;
        }
      } else {
        boolean found = false;
        for(int i=0;i<filter.getSizeInventory() && i < filterInvLimit;i++) {
          ItemIdentifierStack identStack = filter.getIDStackInSlot(i);
          if(identStack == null) continue;
          if(identStack.getItem().equalsWithoutNBT(item)) {
            found = true;
            break;
          }
        }
        if(found) {
          wanteditem = item;
        }
      } 
    }
    if(wanteditem == null) return null;
    int available = invUtil.itemCount(wanteditem);
    if(available == 0) return null;
    if(!_service.useEnergy(neededEnergy() * Math.min(64, available))) {
      return null;
    }
    return invUtil.getMultipleItems(wanteditem, Math.min(64, available));
  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  @Override
  @SuppressWarnings("unchecked")
  public void processPacket(EntityPlayer player) {
    IInventory inv = this.getTile(player.worldObj, IInventory.class);
    if (inv instanceof ISidedInventory) inv = new SidedInventoryMinecraftAdapter((ISidedInventory) inv, ForgeDirection.UNKNOWN, false);
    IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv);Slot result = null;
    if(((List<Slot>)player.openContainer.inventorySlots).get(inventorySlot).slotNumber == inventorySlot) {
      result = ((List<Slot>)player.openContainer.inventorySlots).get(inventorySlot);
    }
    if(result == null) {
      for(Slot slotObject:(List<Slot>)player.openContainer.inventorySlots) {
        if(slotObject.slotNumber == inventorySlot) {
          result = slotObject;
          break;
        }
      }
    }
    if(result == null) {
      player.addChatComponentMessage(new ChatComponentTranslation("lp.chat.slotnotfound"));
    }
    int resultIndex = -1;
    if(resultIndex == -1) {
      ItemStack content = result.getStack();
      if(content != null) {
        for(int i=0;i<util.getSizeInventory();i++) {
          if(content == util.getStackInSlot(i)) {
            resultIndex = i;
            break;
          }
        }
      } else {
        ItemStack dummyStack = new ItemStack(Blocks.stone, 0, 0);
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setBoolean("LPStackFinderBoolean", true); //Make it unique
        dummyStack.setTagCompound(nbt);
        result.putStack(dummyStack);
        for(int i=0;i < util.getSizeInventory();i++) {
          if(dummyStack == util.getStackInSlot(i)) {
            resultIndex = i;
            break;
          }
        }
        if(resultIndex == -1) {
          for(int i=0;i < util.getSizeInventory();i++) {
            ItemStack stack = util.getStackInSlot(i);
            if(stack == null) continue;
            if(ItemIdentifier.get(stack).equals(ItemIdentifier.get(dummyStack)) && stack.stackSize == dummyStack.stackSize) {
              resultIndex = i;
              break;
            }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  @Override
  public void tick() {
    if (++currentTickCount < ticksToAction) return;
    currentTickCount = 0;

    IInventoryUtil inv = _service.getPointedInventory(true);
    if (inv == null) return;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
      ItemStack stack = inv.getStackInSlot(i);
      if (stack == null) continue;
      if (SimpleServiceLocator.IC2Proxy.isElectricItem(stack)) {
        Triplet<Integer, SinkReply, List<IFilter>> reply = SimpleServiceLocator.logisticsManager.hasDestinationWithMinPriority(ItemIdentifier.get(stack), _service.getSourceID(), true, FixedPriority.ElectricManager);
        if(reply == null) continue;
        _service.spawnParticle(Particles.OrangeParticle, 2);
        _service.sendStack(inv.decrStackSize(i, 1), reply, ItemSendMode.Normal);
        return;
      }
      continue;
    }
  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

        if(arrivingItem.getAdditionalTargetInformation() instanceof ITargetSlotInformation) {

          ITargetSlotInformation information = (ITargetSlotInformation) arrivingItem.getAdditionalTargetInformation();
          IInventory inv = (IInventory)tile;
          if(inv instanceof ISidedInventory) inv = new SidedInventoryMinecraftAdapter((ISidedInventory)inv, ForgeDirection.UNKNOWN, false);
          IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv);
          if(util instanceof ISpecialInsertion) {
            int slot = information.getTargetSlot();
            int amount = information.getAmount();
            if(util.getSizeInventory() > slot) {
              ItemStack content = util.getStackInSlot(slot);
              ItemStack toAdd = arrivingItem.getItemIdentifierStack().makeNormalStack();
              toAdd.stackSize = Math.min(toAdd.stackSize, Math.max(0, amount - (content != null ? content.stackSize : 0)));
              if(toAdd.stackSize > 0) {
                if(util.getSizeInventory() > slot) {
                  int added = ((ISpecialInsertion)util).addToSlot(toAdd, slot);
                  arrivingItem.getItemIdentifierStack().lowerStackSize(added);
                  if(added > 0) {
                    tookSome = true;
                  }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  private static final SinkReply _sinkReply = new SinkReply(FixedPriority.PassiveSupplier, 0, true, false, 2, 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 targetUtil = _service.getSneakyInventory(false);
    if (targetUtil == null) return null;
   
    if (!_filterInventory.containsItem(item)) return null;
   
    int targetCount = _filterInventory.itemCount(item);
    int haveCount = targetUtil.itemCount(item);
    if (targetCount <= haveCount) return null;
   
    if(_service.canUseEnergy(2)) {
      return new SinkReply(_sinkReply, targetCount - haveCount);
    }
View Full Code Here

Examples of logisticspipes.interfaces.IInventoryUtil

  @Override
  public void tick() {
    if (extractMode) {
      if (++currentTick < ticksToAction) return;
      currentTick = 0;
      IInventoryUtil inv = _service.getUnsidedInventory();
      if (inv == null) return;
      for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack item = inv.getStackInSlot(i);
        if (SimpleServiceLocator.forestryProxy.isBee(item)) {
          if (SimpleServiceLocator.forestryProxy.isAnalysedBee(item)) {
            Pair<Integer, SinkReply> reply = _service.hasDestination(ItemIdentifier.get(item), true, new ArrayList<Integer>());
            if (reply == null)
              continue;
            if (_service.useEnergy(6)) {
              _service.sendStack(inv.decrStackSize(i, 1), reply, ItemSendMode.Normal);
            }
          }
        }
      }
    }
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.