继续修复部分情况下物品传输条件的判断问题(恼)
This commit is contained in:
parent
7d3b7e6572
commit
bb59072a6a
2 changed files with 14 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue