diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java index 9fa7e8e73..fdedefe24 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java @@ -77,7 +77,18 @@ public class SuperbItemInterfaceBlockEntity extends BaseContainerBlockEntity { for (int i = 0; i < itemHandler.getSlots(); i++) { if (stack.isEmpty()) break; - stack = itemHandler.insertItem(i, stack, false); + int inserted; + for (inserted = stack.getCount(); inserted > 0; inserted--) { + var insertedStack = itemHandler.insertItem(i, stack.copyWithCount(inserted), true); + if (insertedStack.getCount() != inserted || !ItemStack.isSameItemSameComponents(insertedStack, stack)) { + break; + } + } + + if (inserted > 0) { + itemHandler.insertItem(i, stack.copyWithCount(inserted), false); + stack.shrink(inserted); + } } blockEntity.items.set(index, stack); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 982092ed7..a0e9123b9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -232,11 +232,12 @@ public abstract class VehicleEntity extends Entity implements Container { public void setItem(int slot, @NotNull ItemStack pStack) { if (!this.hasContainer() || slot >= this.getContainerSize() || slot < 0) return; - this.items.set(slot, pStack); var limit = Math.min(this.getMaxStackSize(), pStack.getMaxStackSize()); if (!pStack.isEmpty() && pStack.getCount() > limit) { + Mod.LOGGER.warn("try inserting ItemStack {} exceeding the maximum stack size: {}, clamped to {}", pStack.getItem(), limit, limit); pStack.setCount(limit); } + this.items.set(slot, pStack); } @Override