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 authored and SamsTheNerd committed Oct 31, 2024
1 parent 20139eb commit 36febdb
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 @@ -199,7 +200,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 @@ -222,6 +228,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 36febdb

Please sign in to comment.