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