mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
修复配方用途出现trim无法点击的问题
This commit is contained in:
@@ -106,12 +106,14 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
|
||||
if (recipe instanceof AbstractedFixedResultRecipe<?> fixedResult) {
|
||||
this.byResult.computeIfAbsent(fixedResult.result().item().id(), k -> new ArrayList<>()).add(recipe);
|
||||
}
|
||||
HashSet<Key> usedKeys = new HashSet<>();
|
||||
for (Ingredient<T> ingredient : recipe.ingredientsInUse()) {
|
||||
for (UniqueKey holder : ingredient.items()) {
|
||||
Key key = holder.key();
|
||||
if (usedKeys.add(key)) {
|
||||
this.byIngredient.computeIfAbsent(key, k -> new ArrayList<>()).add(recipe);
|
||||
if (recipe.canBeSearchedByIngredients()) {
|
||||
HashSet<Key> usedKeys = new HashSet<>();
|
||||
for (Ingredient<T> ingredient : recipe.ingredientsInUse()) {
|
||||
for (UniqueKey holder : ingredient.items()) {
|
||||
Key key = holder.key();
|
||||
if (usedKeys.add(key)) {
|
||||
this.byIngredient.computeIfAbsent(key, k -> new ArrayList<>()).add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,11 @@ public class CustomSmithingTrimRecipe<T> extends AbstractRecipe<T> {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeSearchedByIngredients() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"DuplicatedCode"})
|
||||
public static class Serializer<A> extends AbstractRecipeSerializer<A, CustomSmithingTrimRecipe<A>> {
|
||||
|
||||
|
||||
@@ -25,4 +25,8 @@ public interface Recipe<T> {
|
||||
default boolean showNotification() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean canBeSearchedByIngredients() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user