Package net.mcft.copy.betterstorage.misc

Examples of net.mcft.copy.betterstorage.misc.ItemIdentifier


    return (isEnabled() ? getPileData().getContents().getRandomStacks() : Collections.EMPTY_LIST);
  }
 
  @Override
  public int getItemCount(ItemStack identifier) {
    return (isEnabled() ? getPileData().getContents().get(new ItemIdentifier(identifier)) : 0);
  }
View Full Code Here


  public ItemStack insertItems(ItemStack stack) {
    return (isEnabled() ? getPileData().addItems(stack) : stack);
  }
  @Override
  public ItemStack extractItems(ItemStack identifier, int amount) {
    return (isEnabled() ? getPileData().removeItems(new ItemIdentifier(identifier), amount) : null);
  }
View Full Code Here

    if (space > 0) {
     
      if (space < stack.stackSize)
        overflow = stack.splitStack(stack.stackSize - space);
     
      ItemIdentifier item = new ItemIdentifier(stack);
      getContents().set(item, getContents().get(item) + stack.stackSize);
     
      for (ICrateWatcher watcher : watchers)
        watcher.onCrateItemsModified(stack);
     
View Full Code Here

  }
  /** Removes and returns a specific amount of items. <br>
   *  Returns less than the requested amount when there's
   *  not enough, or null if there's none at all. */
  public ItemStack removeItems(ItemStack stack) {
    return removeItems(new ItemIdentifier(stack), stack.stackSize);
  }
View Full Code Here

    return space;
  }
  /** Returns how much space there is left for a specific item. */
  public int getSpaceForItem(ItemStack item) {
    if (item == null) return 0;
    return getSpaceForItem(new ItemIdentifier(item));
  }
View Full Code Here

      int damage = stackCompound.getShort("Damage");
      ItemStack stack = new ItemStack(item, count, damage);
      if (stackCompound.hasKey("tag"))
        stack.stackTagCompound = stackCompound.getCompoundTag("tag");
      if (stack.getItem() != null)
        pileData.getContents().set(new ItemIdentifier(stack), stack.stackSize);
    }
    if (compound.hasKey("map"))
      pileData.map = CratePileMap.fromCompound(compound.getCompoundTag("map"));
    return pileData;
  }
View Full Code Here

    data = new MapData();
    countData.put(item, data);
    return data;
  }
  private MapData getMapData(ItemStack item) {
    return getMapData(new ItemIdentifier(item));
  }
View Full Code Here

  public void setInventorySlotContents(int slot, ItemStack stack) {
    if ((slot < 0) || (slot >= getSizeInventory())) return;
    ItemStack oldStack = getStackInSlot(slot);
    ignoreModifiedItems = true;
    if (oldStack != null) {
      ItemIdentifier item = new ItemIdentifier(oldStack);
      getMapData(item).itemCount -= oldStack.stackSize;
      data.removeItems(item, oldStack.stackSize);
    }
    if (stack != null) {
      int amount = Math.min(stack.stackSize,
View Full Code Here

  public ItemStack decrStackSize(int slot, int amount) {
    ItemStack stack = getStackInSlot(slot);
    if (stack == null) return null;
    amount = Math.min(amount, stack.stackSize);
   
    ItemIdentifier item = new ItemIdentifier(stack);
    getMapData(item).itemCount -= amount;
   
    stack.stackSize -= amount;
    if (stack.stackSize <= 0)
      tempContents[slot] = null;
View Full Code Here

 
  @Override
  public void onCrateItemsModified(ItemStack changed) {
    if (ignoreModifiedItems) return;
   
    ItemIdentifier item = new ItemIdentifier(changed);
    int amount = changed.stackSize;
   
    MapData itemData = getMapData(item);
    Queue<Integer> emptySlots = new LinkedList<Integer>();
   
    for (int slot = 0; slot < tempContents.length; slot++) {
      ItemStack stack = tempContents[slot];
      if (stack == null) { emptySlots.add(slot); continue; }
      if (!item.matches(stack)) continue;
      amount -= modifyItemsInSlot(slot, stack, itemData, amount);
      if (amount == 0) return;
    }
   
    while ((amount > 0) && (emptySlots.size() > 0))
View Full Code Here

TOP

Related Classes of net.mcft.copy.betterstorage.misc.ItemIdentifier

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.