Allowed fill crafting grid without all ingredients (#693)

This commit is contained in:
slprime authored and GitHub committed 2025-08-06 13:40:52 -04:00
1 parent 3edb85b317
commit 594fbe6f79
2 files changed
+11 -9

No files matched your search

@@ -82,21 +82,20 @@ public class DefaultOverlayHandler implements IOverlayHandler {
assignIngredSlots(gui, ingredients, assignedIngredients);
multiplier = Math.min(multiplier == 0 ? 64 : multiplier, calculateRecipeQuantity(assignedIngredients));
if (multiplier != 0) {
moveIngredients(gui, assignedIngredients, (int) multiplier);
}
moveIngredients(gui, assignedIngredients, Math.max(1, multiplier));
return multiplier;
return assignedIngredients.stream().anyMatch(distrib -> distrib.distrib.distributed == 0) ? 0 : multiplier;
}
@Override
public boolean canFillCraftingGrid(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex) {
return presenceOverlay(firstGui, handler, recipeIndex).stream().allMatch(state -> state.isPresent());
return true;
}
@Override
public boolean canCraft(GuiContainer firstGui, IRecipeHandler handler, int recipeIndex) {
return canFillCraftingGrid(firstGui, handler, recipeIndex);
return canFillCraftingGrid(firstGui, handler, recipeIndex)
&& presenceOverlay(firstGui, handler, recipeIndex).stream().allMatch(state -> state.isPresent());
}
@Override
@@ -227,6 +226,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
for (IngredientDistribution distrib : assignedIngredients) {
final DistributedIngred istack = distrib.distrib;
if (istack.distributed == 0) continue;
if (istack.numSlots == 0) return 0;
final int maxStackSize = istack.stack.getMaxStackSize();
@@ -318,8 +318,10 @@ public class DefaultOverlayHandler implements IOverlayHandler {
}
}
if (biggestIngred == null) // not enough ingreds
return null;
if (biggestIngred == null) {
biggestIngred = new DistributedIngred(posstack.item);
permutation = InventoryUtils.copyStack(posstack.item, 0);
}
biggestIngred.distributed += permutation.stackSize;
assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
@@ -171,7 +171,7 @@ public class GuiOverlayButton extends GuiRecipeButton {
DrawableResource icon = ICON_OVERLAY;
if (this.hasOverlay && (!this.requireShiftForOverlayRecipe || NEIClientUtils.shiftKey())) {
icon = canFillCraftingGrid() ? ICON_FILL : ICON_FILL_ERROR;
icon = this.missedMaterialsTooltipLineHandler == null ? ICON_FILL : ICON_FILL_ERROR;
}
final int iconX = this.xPosition + (this.width - icon.width - 1) / 2;