Skip to content

Commit c36adf8

Browse files
committed
fix: Re-add locked input to options even if no longer an option, to avoid desync of display in slot and allow scroll to correct #806
1 parent 222737c commit c36adf8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

common/src/main/java/net/blay09/mods/cookingforblockheads/crafting/CraftingOperation.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ public CraftingOperation prepare() {
7676
continue;
7777
}
7878

79-
// TODO Should do this only if we found one, reusing the found ingredientToken
8079
final var options = getIngredientOptions(ingredient);
81-
ingredientOptions.add(options);
8280
final var lockedInput = lockedInputs != null && i < lockedInputs.size() ? lockedInputs.get(i) : ItemStack.EMPTY;
81+
if (options.stream().noneMatch(it -> ItemStack.isSameItemSameComponents(it, lockedInput))) {
82+
options.add(lockedInput);
83+
}
84+
ingredientOptions.add(options);
8385
final var ingredientToken = accountForIngredient(ingredient, lockedInput);
8486
if (ingredientToken != null) {
8587
if (options.size() > 1) {
@@ -147,12 +149,14 @@ private IngredientToken findIngredient(KitchenItemProvider itemProvider, Ingredi
147149
}
148150

149151
private List<ItemStack> getIngredientOptions(Ingredient ingredient) {
152+
final var result = new ArrayList<ItemStack>();
153+
150154
final var candidateItems = ingredient.getItems();
151155
if (candidateItems.length == 1) {
152-
return List.of(candidateItems[0]);
156+
result.add(candidateItems[0]);
157+
return result;
153158
}
154159

155-
final var result = new ArrayList<ItemStack>();
156160
for (final var itemStack : candidateItems) {
157161
if (itemStack.isEmpty()) {
158162
continue;

0 commit comments

Comments
 (0)