Skip to content

Commit

Permalink
fix recurseIngredientTreeAdd returning true on conflicts (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Sep 23, 2023
1 parent f4cf6e7 commit da171a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/recipes/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public String toString() {
.append("EUt", EUt)
.append("hidden", hidden)
.append("CTRecipe", isCTRecipe)
.append("GSRecipe", groovyRecipe)
.toString();
}

Expand Down
24 changes: 22 additions & 2 deletions src/main/java/gregtech/api/recipes/RecipeMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.api.recipes;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.google.common.collect.ImmutableList;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ZenRegister;
Expand Down Expand Up @@ -976,6 +977,18 @@ private boolean recurseIngredientTreeAdd(@Nonnull Recipe recipe, @Nonnull List<L
CraftTweakerAPI.logError("Could not identify exact duplicate/conflict.");
}
}
if (recipe.isGroovyRecipe()) {
GroovyLog log = GroovyLog.get();
log.warn("Recipe duplicate or conflict found in RecipeMap {} and was not added. See next lines for details", this.unlocalizedName);

log.warn("Attempted to add Recipe: {}", recipe.toString());

if (v.left().isPresent()) {
log.warn("Which conflicts with: {}", v.left().get().toString());
} else {
log.warn("Could not find exact duplicate/conflict.");
}
}
if (ConfigHolder.misc.debug || GTValues.isDeobfEnvironment()) {
GTLog.logger.warn("Recipe duplicate or conflict found in RecipeMap {} and was not added. See next lines for details", this.unlocalizedName);

Expand Down Expand Up @@ -1006,8 +1019,15 @@ private boolean recurseIngredientTreeAdd(@Nonnull Recipe recipe, @Nonnull List<L

// left branches are always either empty or contain recipes.
// If there's a recipe present, the addition is finished for this ingredient
// Cannot return here, since each ingredient to add is a separate path to the recipe
if (r.left().isPresent()) continue;
if (r.left().isPresent()) {
if (r.left().get() == recipe) {
// Cannot return here, since each ingredient to add is a separate path to the recipe
continue;
} else {
// exit if a different recipe is already present for this path
return false;
}
}

// recursive part: apply the addition for the next ingredient in the list, for the right branch.
// the right branch only contains ingredients, or is empty when the left branch is present
Expand Down

0 comments on commit da171a7

Please sign in to comment.