From 8b2995d2c45e66fa83292966fea3300e5329008c Mon Sep 17 00:00:00 2001 From: "petrak@" Date: Mon, 5 Jun 2023 21:54:24 -0500 Subject: [PATCH] i forget what this code is doing --- Fabric/gradle.properties | 4 +-- .../hexcasting/fabric/FabricHexConfig.java | 28 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Fabric/gradle.properties b/Fabric/gradle.properties index 59d27dfd..06de2ab5 100644 --- a/Fabric/gradle.properties +++ b/Fabric/gradle.properties @@ -8,10 +8,10 @@ entityReachVersion=2.3.0 emiVersion=0.4.0+1.19 gravityApiVersion=0.7.12+fabric -clothConfigVersion=8.2.88 trinketsVersion=3.4.0 -modmenuVersion=4.1.1 +clothConfigVersion=8.2.88 +modmenuVersion=4.1.2 # Optimizations sodiumVersion=mc1.19.2-0.4.4 diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java index e7e629e2..4d8eb13f 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java @@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.common.loot.HexLootHandler; import at.petrak.hexcasting.xplat.IXplatAbstractions; +import com.google.gson.GsonBuilder; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import me.shedaniel.autoconfig.AutoConfig; @@ -38,7 +39,12 @@ public class FabricHexConfig extends PartitioningSerializer.GlobalData { public final Server server = new Server(); public static FabricHexConfig setup() { - AutoConfig.register(FabricHexConfig.class, PartitioningSerializer.wrap(GsonConfigSerializer::new)); + var gson = new GsonBuilder() + .setPrettyPrinting() + .registerTypeAdapter(ResourceLocation.class, new ResourceLocation.Serializer()) + .create(); + AutoConfig.register(FabricHexConfig.class, PartitioningSerializer.wrap((cfg, clazz) -> + new GsonConfigSerializer<>(cfg, clazz, gson))); var instance = AutoConfig.getConfigHolder(FabricHexConfig.class).getConfig(); HexConfig.setCommon(instance.common); @@ -172,10 +178,11 @@ public class FabricHexConfig extends PartitioningSerializer.GlobalData { @ConfigEntry.Gui.Tooltip private List tpDimDenylist = DEFAULT_DIM_TP_DENYLIST; + // ModMenu bad and doesn't like java objects in here so we do stupid string parsing @ConfigEntry.Gui.Tooltip - private List scrollInjectionsRaw = HexLootHandler.DEFAULT_SCROLL_INJECTS + private List scrollInjectionsRaw = HexLootHandler.DEFAULT_SCROLL_INJECTS .stream() - .map(si -> new ScrollInjectionMirror(si.injectee(), si.countRange())) + .map(si -> si.injectee() + " " + si.countRange()) .toList(); @ConfigEntry.Gui.Excluded private transient Object2IntMap scrollInjections; @@ -193,8 +200,16 @@ public class FabricHexConfig extends PartitioningSerializer.GlobalData { this.maxSpellCircleLength = Math.max(this.maxSpellCircleLength, 4); this.scrollInjections = new Object2IntOpenHashMap<>(); - for (var mirror : this.scrollInjectionsRaw) { - this.scrollInjections.put(mirror.injectee(), mirror.countRange()); + try { + for (var auugh : this.scrollInjectionsRaw) { + String[] split = auugh.split(" "); + ResourceLocation loc = new ResourceLocation(split[0]); + int count = Integer.parseInt(split[1]); + this.scrollInjections.put(loc, count); + } + + } catch (Exception e) { + throw new ValidationException("Bad parsing of scroll injects", e); } this.loreChance = Mth.clamp(this.loreChance, 0.0, 1.0); @@ -249,8 +264,5 @@ public class FabricHexConfig extends PartitioningSerializer.GlobalData { public double getLoreChance() { return loreChance; } - - record ScrollInjectionMirror(ResourceLocation injectee, int countRange) { - } } }