Fix MatteryContainer not adding items properly

This commit is contained in:
DBotThePony 2021-09-18 17:14:57 +07:00
parent d9baced685
commit ee2c3241d4
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -193,7 +193,7 @@ public class MatteryContainer implements Container, Iterable<ItemStack> {
if (stack.isEmpty() || start < 0 || end > size || start >= end)
return ItemStack.EMPTY;
var copy = stack.copy();
final var copy = stack.copy();
// двигаем в одинаковые слоты
for (int slot = start; slot < end; slot++) {
@ -229,6 +229,7 @@ public class MatteryContainer implements Container, Iterable<ItemStack> {
if (!simulate) {
var put_copy = copy.copy();
put_copy.setCount(diff);
slots[slot] = put_copy;
tracked_slots[slot] = put_copy.copy();
setChanged(slot, put_copy, ItemStack.EMPTY);
}
@ -244,10 +245,12 @@ public class MatteryContainer implements Container, Iterable<ItemStack> {
return copy;
}
@SuppressWarnings("unused")
public ItemStack addItem(ItemStack stack, boolean simulate) {
return addItem(stack, 0, size, simulate);
}
@SuppressWarnings("unused")
public ItemStack addItem(ItemStack stack) {
return addItem(stack, 0, size, false);
}
@ -260,6 +263,7 @@ public class MatteryContainer implements Container, Iterable<ItemStack> {
return addItem(stack, 0, size, false).isEmpty();
}
@SuppressWarnings("unused")
public boolean fullyAddItem(ItemStack stack, int start, int end) {
if (!addItem(stack, start, end, true).isEmpty()) {
return false;