Skip to content

Commit

Permalink
shapeless recipe counter: slightly more conservative check to avoid i…
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 6, 2023
1 parent b62926e commit 07035dd
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -3,10 +3,7 @@
import org.bukkit.Material;
import org.bukkit.inventory.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;

public class RecipeHelper {

Expand Down Expand Up @@ -78,11 +75,13 @@ public static int getShapedQuantity(CraftingInventory inventory, ShapeHelper sha
}

public static boolean tryRemoveSingle(List<ItemStack> items, List<RecipeChoice> choices) {
HashSet<Integer> used = new HashSet<>();
mainLoop:
for (RecipeChoice choice : choices) {
for (int i = 0; i < items.size(); i++) {
ItemStack item = items.get(i);
if (choice.test(item)) {
if (choice.test(item) && !used.contains(i)) {
used.add(i);
if (item.getAmount() == 1) {
items.remove(i);
}
Expand Down

0 comments on commit 07035dd

Please sign in to comment.