Skip to content

Commit

Permalink
Copy scrollInjections config trick for loreInjections
Browse files Browse the repository at this point in the history
  • Loading branch information
vgskye committed Aug 23, 2024
1 parent b4aa319 commit 19b67c9
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ResourceLocation> loreInjections = HexLootHandler.DEFAULT_LORE_INJECTS;
private List<String> loreInjectionsRaw = HexLootHandler.DEFAULT_LORE_INJECTS
.stream()
.map(ResourceLocation::toString)
.toList();
@ConfigEntry.Gui.Excluded
private transient List<ResourceLocation> loreInjections;
@ConfigEntry.Gui.Tooltip
private double loreChance = HexLootHandler.DEFAULT_LORE_CHANCE;

Expand All @@ -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);
}

Expand Down

0 comments on commit 19b67c9

Please sign in to comment.