9
0
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:
XiaoMoMi
2025-09-16 22:48:23 +08:00
parent 35807d7a21
commit 5bfc2be9c9
3 changed files with 17 additions and 6 deletions

View File

@@ -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);
}
}
}
}

View File

@@ -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>> {

View File

@@ -25,4 +25,8 @@ public interface Recipe<T> {
default boolean showNotification() {
return true;
}
default boolean canBeSearchedByIngredients() {
return true;
}
}