From bb59072a6a1f0c419d6d26d9f0ed410443c9e563 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Sun, 13 Jul 2025 21:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=83=85=E5=86=B5=E4=B8=8B=E7=89=A9=E5=93=81=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=E6=9D=A1=E4=BB=B6=E7=9A=84=E5=88=A4=E6=96=AD=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=88=E6=81=BC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/SuperbItemInterfaceBlockEntity.java | 13 ++++++++++++- .../entity/vehicle/base/VehicleEntity.java | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) 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