fixed non-stackable items not playing nice with the crafting terminal

This commit is contained in:
Ell 2020-10-17 17:24:24 +02:00
parent ae5b81e933
commit 64e2b9c4fe

View file

@ -166,7 +166,10 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
for (int i = 0; i < tile.craftItems.getSlots(); i++) { for (int i = 0; i < tile.craftItems.getSlots(); i++) {
ItemStack stack = tile.getRequestedCraftItem(i); ItemStack stack = tile.getRequestedCraftItem(i);
int count = tile.isGhostItem(i) ? 0 : stack.getCount(); int count = tile.isGhostItem(i) ? 0 : stack.getCount();
if (!ItemHandlerHelper.canItemStacksStackRelaxed(stack, remain)) if (!ItemHandlerHelper.canItemStacksStack(stack, remain))
continue;
// ensure that a single non-stackable item can still enter a ghost slot
if (!stack.isStackable() && count >= 1)
continue; continue;
if (lowestSlot < 0 || !tile.isGhostItem(lowestSlot) && count < tile.getRequestedCraftItem(lowestSlot).getCount()) if (lowestSlot < 0 || !tile.isGhostItem(lowestSlot) && count < tile.getRequestedCraftItem(lowestSlot).getCount())
lowestSlot = i; lowestSlot = i;
@ -197,7 +200,8 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
continue; continue;
MutableInt amount = requiredItems.computeIfAbsent(new EquatableItemStack(requested), s -> new MutableInt()); MutableInt amount = requiredItems.computeIfAbsent(new EquatableItemStack(requested), s -> new MutableInt());
amount.add(requested.getCount()); amount.add(requested.getCount());
int fit = requested.getMaxStackSize() - (isGhost.test(i) ? 0 : requested.getCount()); // if no items fit into the crafting input, we still want to pretend they do for requesting
int fit = Math.max(requested.getMaxStackSize() - (isGhost.test(i) ? 0 : requested.getCount()), 1);
if (lowestAvailable > fit) if (lowestAvailable > fit)
lowestAvailable = fit; lowestAvailable = fit;
} }