From 7d3b7e6572814a4aefe4e2760a514d1f52b98b7b Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Sun, 13 Jul 2025 21:16:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E7=89=A9=E5=93=81=E4=BC=A0=E8=BE=93=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=88=A4=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vehicle/base/VehicleEntity.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 9fe5dc644..982092ed7 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 @@ -233,8 +233,9 @@ public abstract class VehicleEntity extends Entity implements Container { if (!this.hasContainer() || slot >= this.getContainerSize() || slot < 0) return; this.items.set(slot, pStack); - if (!pStack.isEmpty() && pStack.getCount() > this.getMaxStackSize()) { - pStack.setCount(this.getMaxStackSize()); + var limit = Math.min(this.getMaxStackSize(), pStack.getMaxStackSize()); + if (!pStack.isEmpty() && pStack.getCount() > limit) { + pStack.setCount(limit); } } @@ -268,6 +269,15 @@ public abstract class VehicleEntity extends Entity implements Container { @Override public boolean canPlaceItem(int slot, @NotNull ItemStack stack) { if (!this.hasContainer() || slot >= this.getContainerSize() || slot < 0) return false; + + var currentStack = this.items.get(slot); + if (!currentStack.isEmpty() && currentStack.getItem() != stack.getItem()) return false; + + var currentCount = currentStack.getCount(); + var stackCount = stack.getCount(); + int combinedCount = currentCount + stackCount; + if (combinedCount > this.getMaxStackSize() || combinedCount > stack.getMaxStackSize()) return false; + return Container.super.canPlaceItem(slot, stack); } @@ -492,6 +502,7 @@ public abstract class VehicleEntity extends Entity implements Container { } // energy start + /** * 消耗指定电量 *