rename strict mode to compare all

This commit is contained in:
rlnt 2024-08-22 22:25:42 +02:00
parent 14044f3b57
commit 448d2a9dfe
No known key found for this signature in database
3 changed files with 11 additions and 11 deletions

View file

@ -19,17 +19,17 @@ public final class DuplicateConfig extends Config {
private final LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules;
private final Set<Pattern> ignoreRecipeTypes;
private final Set<Pattern> ignoreRecipeIds;
private final boolean strictMode;
private final boolean compareAll;
private final Map<ResourceLocation, Boolean> ignoredRecipeTypesCache;
private DuplicateConfig(JsonCompare.CompareSettings defaultRules, LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules, Set<Pattern> ignoreRecipeTypes, Set<Pattern> ignoreRecipeIds, boolean strictMode) {
private DuplicateConfig(JsonCompare.CompareSettings defaultRules, LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules, Set<Pattern> ignoreRecipeTypes, Set<Pattern> ignoreRecipeIds, boolean compareAll) {
super(NAME);
this.defaultRules = defaultRules;
this.overrideRules = overrideRules;
this.ignoreRecipeTypes = ignoreRecipeTypes;
this.ignoreRecipeIds = ignoreRecipeIds;
this.strictMode = strictMode;
this.compareAll = compareAll;
this.ignoredRecipeTypesCache = new HashMap<>();
}
@ -68,8 +68,8 @@ public final class DuplicateConfig extends Config {
return overrideRules.getOrDefault(type, defaultRules);
}
public boolean isStrictMode() {
return strictMode;
public boolean shouldCompareAll() {
return compareAll;
}
public void clearCache() {
@ -82,7 +82,7 @@ public final class DuplicateConfig extends Config {
private static final String OVERRIDE_DUPLICATE_RULES = "override_duplicate_rules";
private static final String IGNORED_RECIPE_TYPES = "ignored_recipe_types";
private static final String IGNORED_RECIPE_IDS = "ignored_recipe_ids";
private static final String STRICT_MODE = "strict_mode";
private static final String COMPARE_ALL = "compare_all";
private DuplicateSerializer() {}
@ -101,14 +101,14 @@ public final class DuplicateConfig extends Config {
Defaults.getDefaultDuplicateRules(platform));
LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules = safeGet(() -> getOverrideRules(
json), Defaults.getDefaultDuplicateOverrides(platform));
boolean strictMode = safeGet(() -> json.get(STRICT_MODE).getAsBoolean(), false);
boolean compareAll = safeGet(() -> json.get(COMPARE_ALL).getAsBoolean(), false);
return new DuplicateConfig(
defaultRules,
overrideRules,
ignoreRecipeTypes,
ignoreRecipeIds,
strictMode
compareAll
);
}
@ -142,7 +142,7 @@ public final class DuplicateConfig extends Config {
config.overrideRules.forEach((rl, compareSettings) ->
overrides.add(rl.toString(), compareSettings.serialize()));
json.add(OVERRIDE_DUPLICATE_RULES, overrides);
json.addProperty(STRICT_MODE, false);
json.addProperty(COMPARE_ALL, false);
return json;
}

View file

@ -86,7 +86,7 @@ public class RecipeTransformer {
*/
private void transformRecipes(List<RecipeLink> recipeLinks, Map<ResourceLocation, JsonElement> allRecipes, @Nullable ClientRecipeTracker.RawBuilder tracker) {
var unified = unifyRecipes(recipeLinks, r -> allRecipes.put(r.getId(), r.getUnified()));
var duplicates = handleDuplicates(duplicateConfig.isStrictMode() ? recipeLinks : unified, recipeLinks);
var duplicates = handleDuplicates(duplicateConfig.shouldCompareAll() ? recipeLinks : unified, recipeLinks);
duplicates
.stream()
.flatMap(d -> d.getRecipesWithoutMaster().stream())

View file

@ -31,5 +31,5 @@
"should_sanitize": false
}
},
"strict_mode": false
"compare_all": false
}