예제 #1
0
 public ItemStack take(ItemStack template, int amount) {
   Key k = Key.of(template);
   Integer count = _elements.get(k);
   if (count == null) return null;
   ItemStack stack = k.stack().copy();
   stack.stackSize =
       Math.min(stack.getMaxStackSize(), Math.min(SLOT_STACK_LIMIT, Math.min(amount, count)));
   _size -= stack.stackSize;
   if (stack.stackSize >= count) _elements.remove(k);
   else _elements.put(k, count - stack.stackSize);
   return stack;
 }
예제 #2
0
 public Collection<ItemStack> allowed() {
   List<ItemStack> list = new LinkedList<>();
   for (Key k : _whitelist) list.add(k.stack());
   return list;
 }
예제 #3
0
 public int get(int amount) {
   return Math.min(_key.stack().getMaxStackSize(), Math.min(amount, _count));
 }