Package logisticspipes.utils.item

Examples of logisticspipes.utils.item.ItemIdentifierStack


      if(itemNBT.hasKey("nbt")) {
        tag = itemNBT.getCompoundTag("nbt");
      }
      ItemIdentifier item = ItemIdentifier.get(Item.getItemById(itemID), itemData, tag);
      int amount = itemNBT.getInteger("amount");
      ItemIdentifierStack stack = new ItemIdentifierStack(item, amount);
      macroItems.add(stack);
    }
  }
View Full Code Here


  }

  private ItemIdentifierStack getContents(){
    ItemStack[] data = _tile.getStoredItemData();
    if(data == null || data.length < 1 || data[0] == null || data[0].getItem() == null) return null;
    ItemIdentifierStack dataIdent = ItemIdentifierStack.getFromStack(data[0]);
    for(int i = 0; i < 3; i++) {
      ItemStack stack = ((IInventory)_tile).getStackInSlot(i);
      if(stack != null && ItemIdentifier.get(stack).equals(dataIdent.getItem())) {
        dataIdent.setStackSize(dataIdent.getStackSize() + stack.stackSize);
      }
    }
    return dataIdent;
  }
View Full Code Here

  @Override
  public ItemStack add(ItemStack stack, ForgeDirection from, boolean doAdd) {
    ItemIdentifier itemIdent = ItemIdentifier.get(stack);
    ItemStack st = stack.copy();
    st.stackSize = 0;
    ItemIdentifierStack content = getContents();
    if(content == null) return st;
    if(!content.getItem().equals(itemIdent)) return st;

    if(!doAdd) {
      int space = _tile.getMaxItemCount() + 3 * itemIdent.getMaxStackSize() - content.getStackSize();
      st.stackSize = Math.max(Math.min(space, stack.stackSize), 0);
      return st;
    }

    //add to output slot first
View Full Code Here

    return new DigitalChestHandler((IDigitalChest)tile, hideOnePerStack, hideOne, cropStart, cropEnd);
  }

  @Override
  public int itemCount(ItemIdentifier itemIdent) {
    ItemIdentifierStack content = getContents();
    if(content == null) return 0;
    if(!content.getItem().equals(itemIdent)) return 0;
    return content.getStackSize() - (_hideOnePerStack?1:0);
  }
View Full Code Here

  }

  @Override
  public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> result = new TreeSet<ItemIdentifier>();
    ItemIdentifierStack content = getContents();
    if(content != null) {
      result.add(content.getItem());
    }
    return result;
  }
View Full Code Here

    return result;
  }
  @Override
  public HashMap<ItemIdentifier, Integer> getItemsAndCount() {
    HashMap<ItemIdentifier, Integer> map = new HashMap<ItemIdentifier, Integer>();
    ItemIdentifierStack content = getContents();
    if(content != null) {
      map.put(content.getItem(), content.getStackSize() - (_hideOnePerStack?1:0));
    }
    return map;
  }
View Full Code Here

    return getMultipleItems(itemIdent,1);
  }

  @Override
  public boolean containsItem(ItemIdentifier itemIdent) {
    ItemIdentifierStack content = getContents();
    if(content == null) return false;
    return itemIdent.equals(content.getItem());
  }
View Full Code Here

    return itemIdent.equals(content.getItem());
  }

  @Override
  public boolean containsUndamagedItem(ItemIdentifier itemIdent) {
    ItemIdentifierStack content = getContents();
    if(content == null) return false;
    return itemIdent.getUndamaged().equals(content.getItem().getUndamaged());
  }
View Full Code Here

    return roomForItem(item, 0);
  }

  @Override
  public int roomForItem(ItemIdentifier itemIdent, int count) {
    ItemIdentifierStack content = getContents();
    if(content == null) return 0;
    if(!content.getItem().equals(itemIdent)) return 0;
    return _tile.getMaxItemCount() + 3 * itemIdent.getMaxStackSize() - content.getStackSize();
  }
View Full Code Here

  }

  @Override
  public ItemStack getMultipleItems(ItemIdentifier itemIdent, int count) {
    //check that we can actually get what we want
    ItemIdentifierStack content = getContents();
    if(content == null) return null;
    if(!content.getItem().equals(itemIdent)) return null;
    if(content.getStackSize() < count) return null;

    //set up the finished stack to return
    ItemStack resultstack = content.makeNormalStack();
    resultstack.stackSize = count;

    //empty input slots first
    for(int i = 1; count > 0 && i < 3; i++) {
      ItemStack stack = ((IInventory)_tile).getStackInSlot(i);
View Full Code Here

TOP

Related Classes of logisticspipes.utils.item.ItemIdentifierStack

Copyright © 2018 www.massapicom. 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.