Skip to content

Commit f3edb1c

Browse files
authored
Copy scrollInjections config trick for loreInjections (#736)
2 parents 20139eb + 36febdb commit f3edb1c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.minecraft.util.Mth;
1919
import net.minecraft.world.level.Level;
2020

21+
import java.util.ArrayList;
2122
import java.util.List;
2223

2324
import static at.petrak.hexcasting.api.mod.HexConfig.anyMatchResLoc;
@@ -199,7 +200,12 @@ public static final class Server implements HexConfig.ServerConfigAccess, Config
199200

200201
// TODO: hook this up to the config, change Jankery, test, also test scroll injects on fabric
201202
@ConfigEntry.Gui.Tooltip
202-
private List<ResourceLocation> loreInjections = HexLootHandler.DEFAULT_LORE_INJECTS;
203+
private List<String> loreInjectionsRaw = HexLootHandler.DEFAULT_LORE_INJECTS
204+
.stream()
205+
.map(ResourceLocation::toString)
206+
.toList();
207+
@ConfigEntry.Gui.Excluded
208+
private transient List<ResourceLocation> loreInjections;
203209
@ConfigEntry.Gui.Tooltip
204210
private double loreChance = HexLootHandler.DEFAULT_LORE_CHANCE;
205211

@@ -222,6 +228,16 @@ public void validatePostLoad() throws ValidationException {
222228
throw new ValidationException("Bad parsing of scroll injects", e);
223229
}
224230

231+
this.loreInjections = new ArrayList<>();
232+
try {
233+
for (var table : this.loreInjectionsRaw) {
234+
ResourceLocation loc = new ResourceLocation(table);
235+
this.loreInjections.add(loc);
236+
}
237+
} catch (Exception e) {
238+
throw new ValidationException("Bad parsing of lore injects", e);
239+
}
240+
225241
this.loreChance = Mth.clamp(this.loreChance, 0.0, 1.0);
226242
}
227243

0 commit comments

Comments
 (0)