9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-29 03:49:15 +00:00

Update BukkitRecipeManager.java

This commit is contained in:
XiaoMoMi
2025-03-20 03:30:41 +08:00
parent 70aa917cfb
commit e70d8703fe

View File

@@ -382,9 +382,13 @@ public class BukkitRecipeManager implements RecipeManager<ItemStack> {
this.byType.computeIfAbsent(recipe.type(), k -> new ArrayList<>()).add(recipe);
this.byId.put(id, recipe);
this.byResult.computeIfAbsent(recipe.result().item().id(), k -> new ArrayList<>()).add(recipe);
HashSet<Key> usedKeys = new HashSet<>();
for (Ingredient<ItemStack> ingredient : recipe.ingredientsInUse()) {
for (Holder<Key> holder : ingredient.items().stream().distinct().toList()) {
this.byIngredient.computeIfAbsent(holder.value(), k -> new ArrayList<>()).add(recipe);
for (Holder<Key> holder : ingredient.items()) {
Key key = holder.value();
if (usedKeys.add(key)) {
this.byIngredient.computeIfAbsent(key, k -> new ArrayList<>()).add(recipe);
}
}
}
}