for (ItemStack itemStackInternal : container) {
if (merge(itemStackInternal, itemStack, positiveOnly ? ((i, j) -> j > i ? 0 : j > 0 ? i - j : i) : add ? ((i, j) -> i + j) : ((i, j) -> i - j)))
return;</BUG>
}
ItemStack stack = itemStack.copy();
<BUG>if (!add) {
NBT.setAmount(stack, -NBT.getAmount(stack));

}</BUG>
container.add(stack);

for (ItemStack itemStackInternal : container) {
if (merge(itemStackInternal, itemStack, type.getFunc()))
return;
}
ItemStack stack = itemStack.copy();
NBT.setAmount(stack, type.getFunc().apply(0L, NBT.getAmount(stack)));
container.add(stack);
