继续修复部分情况下物品传输条件的判断问题(恼)

This commit is contained in:
Light_Quanta 2025-07-13 21:52:04 +08:00
parent 7d3b7e6572
commit bb59072a6a
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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