Skip to content

Commit

Permalink
Fix Issue with GS Reloading and Discarding Trees
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jan 12, 2025
1 parent 4e830f4 commit cb27f5a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

public class RecipeMapLogic {

private static boolean outputBranchesCleared = false;

private static final WeakHashMap<AbstractMapIngredient, WeakReference<AbstractMapIngredient>> outputRoot = new WeakHashMap<>();

private static final WeakHashMap<AbstractMapIngredient, WeakReference<AbstractMapIngredient>> fluidOutputRoot = new WeakHashMap<>();
Expand All @@ -47,6 +49,7 @@ public static void clearAll() {
LabsConfig.groovyScriptSettings.gtRecipeSearchMode ==
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH) {
NomiLabs.LOGGER.info("Clearing Output Branches and Output Maps...");
outputBranchesCleared = true;
OutputBranch.clearAll();
outputRoot.clear();
fluidOutputRoot.clear();
Expand All @@ -57,7 +60,7 @@ public static void clearAll() {

public static void add(@NotNull Recipe recipe, @NotNull OutputBranch branch) {
if (LabsConfig.groovyScriptSettings.gtRecipeSearchMode ==
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH)
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH || outputBranchesCleared)
return;
var list = getOutputFromRecipe(recipe);
recurseOutputTreeAdd(recipe, list, branch, 0, 0);
Expand Down Expand Up @@ -91,7 +94,7 @@ private static void recurseOutputTreeAdd(@NotNull Recipe recipe, @NotNull List<A

public static void remove(@NotNull Recipe recipe, @NotNull OutputBranch branch) {
if (LabsConfig.groovyScriptSettings.gtRecipeSearchMode ==
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH)
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH || outputBranchesCleared)
return;
var list = getOutputFromRecipe(recipe);
recurseOutputTreeRemove(recipe, list, branch);
Expand Down Expand Up @@ -181,9 +184,7 @@ public static List<Recipe> find(@NotNull OutputBranch branch, @NotNull RecipeMap
var list = prepareOutputFind(items, fluids, chancedItems, chancedFluids);
if (list == null) return null;
if (LabsConfig.groovyScriptSettings.gtRecipeSearchMode ==
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH ||
(!map.getRecipesByCategory().isEmpty() && branch.isEmpty())) // If Has Recipes, but Output Branch has
// been Cleared (DISCARDED_TREE)
LabsConfig.GroovyScriptSettings.GTRecipeSearchMode.LINEAR_SEARCH || outputBranchesCleared)
return linearFind(map, list, predicate);
return recurseOutputTreeFindRecipe(list, branch, predicate);
}
Expand Down

0 comments on commit cb27f5a

Please sign in to comment.