Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public Collection<ItemStack> allowed() {
   List<ItemStack> list = new LinkedList<>();
   for (Key k : _whitelist) list.add(k.stack());
   return list;
 }
Exemplo n.º 3
0
 public int get(int amount) {
   return Math.min(_key.stack().getMaxStackSize(), Math.min(amount, _count));
 }