mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-28 10:35:38 -05:00
make more default options platform specific
This commit is contained in:
parent
f730fa0929
commit
8df653de54
4 changed files with 47 additions and 28 deletions
|
@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning].
|
|||
### Added
|
||||
- more materials and another tag to defaults
|
||||
- back up your `unify.json` config and let it regenerate to get the new default or add it yourself
|
||||
- `fabric:conditions` to default duplicate ignore list
|
||||
|
||||
### Changed
|
||||
- ignore lists in `unify.json` and `duplicates.json` now support regular expressions
|
||||
- default configs are now more platform specific
|
||||
|
||||
### Fixed
|
||||
- a compat issue on Fabric when REI is present
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.almostreliable.unified.config;
|
||||
|
||||
import com.almostreliable.unified.Platform;
|
||||
import com.almostreliable.unified.utils.JsonCompare;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
|
@ -68,7 +71,6 @@ public final class Defaults {
|
|||
"uranium",
|
||||
"zinc"
|
||||
);
|
||||
public static final List<String> IGNORED_RECIPE_TYPES = List.of("cucumber:shaped_tag");
|
||||
|
||||
private Defaults() {}
|
||||
|
||||
|
@ -98,7 +100,7 @@ public final class Defaults {
|
|||
"c:plates/{material}",
|
||||
"c:rods/{material}",
|
||||
"c:storage_blocks/{material}",
|
||||
// Modder's just can't decide
|
||||
// Modders just can't decide
|
||||
"c:{material}_nuggets",
|
||||
"c:{material}_dusts",
|
||||
"c:{material}_gears",
|
||||
|
@ -112,4 +114,38 @@ public final class Defaults {
|
|||
);
|
||||
};
|
||||
}
|
||||
|
||||
public static List<String> getIgnoredRecipeTypes(Platform platform) {
|
||||
return switch (platform) {
|
||||
case FORGE -> List.of("cucumber:shaped_tag");
|
||||
case FABRIC -> List.of();
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonCompare.CompareSettings getDefaultDuplicateRules(Platform platform) {
|
||||
JsonCompare.CompareSettings result = new JsonCompare.CompareSettings();
|
||||
result.ignoreField(switch (platform) {
|
||||
case FORGE -> "conditions";
|
||||
case FABRIC -> "fabric:conditions";
|
||||
});
|
||||
result.ignoreField("group");
|
||||
result.addRule("cookingtime", new JsonCompare.HigherRule());
|
||||
result.addRule("energy", new JsonCompare.HigherRule());
|
||||
result.addRule("experience", new JsonCompare.HigherRule());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> getDefaultDuplicateOverrides(Platform platform) {
|
||||
JsonCompare.CompareSettings result = new JsonCompare.CompareSettings();
|
||||
result.ignoreField(switch (platform) {
|
||||
case FORGE -> "conditions";
|
||||
case FABRIC -> "fabric:conditions";
|
||||
});
|
||||
result.ignoreField("group");
|
||||
result.ignoreField("pattern");
|
||||
result.ignoreField("key");
|
||||
LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put(new ResourceLocation("minecraft", "crafting_shaped"), result);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.almostreliable.unified.config;
|
||||
|
||||
import com.almostreliable.unified.AlmostUnifiedPlatform;
|
||||
import com.almostreliable.unified.recipe.RecipeLink;
|
||||
import com.almostreliable.unified.utils.JsonCompare;
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -50,14 +51,15 @@ public class DuplicationConfig extends Config {
|
|||
|
||||
@Override
|
||||
public DuplicationConfig deserialize(JsonObject json) {
|
||||
var platform = AlmostUnifiedPlatform.INSTANCE.getPlatform();
|
||||
Set<Pattern> ignoreRecipeTypes = deserializePatterns(json,
|
||||
IGNORED_RECIPE_TYPES,
|
||||
Defaults.IGNORED_RECIPE_TYPES);
|
||||
Defaults.getIgnoredRecipeTypes(platform));
|
||||
Set<Pattern> ignoreRecipes = deserializePatterns(json, IGNORED_RECIPES, List.of());
|
||||
|
||||
JsonCompare.CompareSettings defaultRules = safeGet(() -> createCompareSet(json.getAsJsonObject(
|
||||
DEFAULT_DUPLICATE_RULES)),
|
||||
defaultSettings());
|
||||
Defaults.getDefaultDuplicateRules(platform));
|
||||
LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules = safeGet(() -> json
|
||||
.getAsJsonObject(OVERRIDE_DUPLICATE_RULES)
|
||||
.entrySet()
|
||||
|
@ -65,33 +67,12 @@ public class DuplicationConfig extends Config {
|
|||
.collect(Collectors.toMap(entry -> new ResourceLocation(entry.getKey()),
|
||||
entry -> createCompareSet(entry.getValue().getAsJsonObject()),
|
||||
(a, b) -> b,
|
||||
LinkedHashMap::new)), defaultOverrides());
|
||||
LinkedHashMap::new)), Defaults.getDefaultDuplicateOverrides(platform));
|
||||
boolean strictMode = safeGet(() -> json.get(STRICT_MODE).getAsBoolean(), false);
|
||||
|
||||
return new DuplicationConfig(defaultRules, overrideRules, ignoreRecipeTypes, ignoreRecipes, strictMode);
|
||||
}
|
||||
|
||||
private JsonCompare.CompareSettings defaultSettings() {
|
||||
JsonCompare.CompareSettings result = new JsonCompare.CompareSettings();
|
||||
result.ignoreField("conditions");
|
||||
result.ignoreField("group");
|
||||
result.addRule("cookingtime", new JsonCompare.HigherRule());
|
||||
result.addRule("energy", new JsonCompare.HigherRule());
|
||||
result.addRule("experience", new JsonCompare.HigherRule());
|
||||
return result;
|
||||
}
|
||||
|
||||
private LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> defaultOverrides() {
|
||||
JsonCompare.CompareSettings result = new JsonCompare.CompareSettings();
|
||||
result.ignoreField("conditions");
|
||||
result.ignoreField("group");
|
||||
result.ignoreField("pattern");
|
||||
result.ignoreField("key");
|
||||
LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put(new ResourceLocation("minecraft", "crafting_shaped"), result);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private JsonCompare.CompareSettings createCompareSet(JsonObject rules) {
|
||||
JsonCompare.CompareSettings result = new JsonCompare.CompareSettings();
|
||||
result.deserialize(rules);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class UnifyConfig extends Config {
|
|||
.collect(Collectors.toSet()), new HashSet<>());
|
||||
Set<Pattern> ignoredRecipeTypes = deserializePatterns(json,
|
||||
IGNORED_RECIPE_TYPES,
|
||||
Defaults.IGNORED_RECIPE_TYPES);
|
||||
Defaults.getIgnoredRecipeTypes(AlmostUnifiedPlatform.INSTANCE.getPlatform()));
|
||||
Set<Pattern> ignoredRecipes = deserializePatterns(json, IGNORED_RECIPES, List.of());
|
||||
boolean hideJeiRei = safeGet(() -> json.getAsJsonPrimitive(HIDE_JEI_REI).getAsBoolean(), true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue