fixed batch crafting requests being calculated incorrectly when auto-crafting

This commit is contained in:
Ell 2020-10-15 06:25:10 +02:00
parent 6ae511e485
commit f74ffc4629

View file

@ -28,6 +28,7 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -108,7 +109,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
network.startProfile("terminal_request_crafting"); network.startProfile("terminal_request_crafting");
this.updateItems(); this.updateItems();
// get the amount of crafts that we can do // get the amount of crafts that we can do
int lowestAvailable = getAvailableCrafts(pipe, this.craftItems.getSlots(), this::getRequestedCraftItem, this::isGhostItem, s -> { int lowestAvailable = getAvailableCrafts(pipe, this.craftItems.getSlots(), i -> ItemHandlerHelper.copyStackWithSize(this.getRequestedCraftItem(i), 1), this::isGhostItem, s -> {
NetworkItem item = this.networkItems.get(s); NetworkItem item = this.networkItems.get(s);
return item != null ? item.getLocations() : Collections.emptyList(); return item != null ? item.getLocations() : Collections.emptyList();
}, onItemUnavailable(player), ItemEqualityType.NBT); }, onItemUnavailable(player), ItemEqualityType.NBT);
@ -163,7 +164,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
if (requested.isEmpty()) if (requested.isEmpty())
continue; continue;
MutableInt amount = requiredItems.computeIfAbsent(new EquatableItemStack(requested), s -> new MutableInt()); MutableInt amount = requiredItems.computeIfAbsent(new EquatableItemStack(requested), s -> new MutableInt());
amount.add(1); amount.add(requested.getCount());
int fit = requested.getMaxStackSize() - (isGhost.test(i) ? 0 : requested.getCount()); int fit = requested.getMaxStackSize() - (isGhost.test(i) ? 0 : requested.getCount());
if (lowestAvailable > fit) if (lowestAvailable > fit)
lowestAvailable = fit; lowestAvailable = fit;