From 19b67c982a4e6fb632d21410eb25542055747686 Mon Sep 17 00:00:00 2001 From: Skye Date: Sat, 24 Aug 2024 00:33:15 +0900 Subject: [PATCH] Copy scrollInjections config trick for loreInjections --- .../hexcasting/fabric/FabricHexConfig.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 7622e7cf8f..d9a5571c3c 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java @@ -18,6 +18,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.level.Level; +import java.util.ArrayList; import java.util.List; import static at.petrak.hexcasting.api.mod.HexConfig.anyMatchResLoc; @@ -192,7 +193,12 @@ public static final class Server implements HexConfig.ServerConfigAccess, Config // TODO: hook this up to the config, change Jankery, test, also test scroll injects on fabric @ConfigEntry.Gui.Tooltip - private List loreInjections = HexLootHandler.DEFAULT_LORE_INJECTS; + private List loreInjectionsRaw = HexLootHandler.DEFAULT_LORE_INJECTS + .stream() + .map(ResourceLocation::toString) + .toList(); + @ConfigEntry.Gui.Excluded + private transient List loreInjections; @ConfigEntry.Gui.Tooltip private double loreChance = HexLootHandler.DEFAULT_LORE_CHANCE; @@ -215,6 +221,16 @@ public void validatePostLoad() throws ValidationException { throw new ValidationException("Bad parsing of scroll injects", e); } + this.loreInjections = new ArrayList<>(); + try { + for (var table : this.loreInjectionsRaw) { + ResourceLocation loc = new ResourceLocation(table); + this.loreInjections.add(loc); + } + } catch (Exception e) { + throw new ValidationException("Bad parsing of lore injects", e); + } + this.loreChance = Mth.clamp(this.loreChance, 0.0, 1.0); }