修复部分情况下物品传输条件的判断问题
This commit is contained in:
parent
24b04c1176
commit
7d3b7e6572
1 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
||||
/**
|
||||
* 消耗指定电量
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue