修复部分情况下物品传输条件的判断问题

This commit is contained in:
Light_Quanta 2025-07-13 21:16:17 +08:00
parent 24b04c1176
commit 7d3b7e6572
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -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
/**
* 消耗指定电量
*