From d8486c138cd42683189776c8cd5b240c819026d7 Mon Sep 17 00:00:00 2001 From: Skye Date: Thu, 22 Aug 2024 20:54:26 +0900 Subject: [PATCH] Turn loreInjections and DEFAULT_LORE_INJECTS into strings for Auto Config --- .../common/loot/HexLootHandler.java | 24 +++++++++---------- .../hexcasting/fabric/FabricHexConfig.java | 6 ++--- .../forge/datagen/ForgeHexLootModGen.java | 5 ++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/loot/HexLootHandler.java b/Common/src/main/java/at/petrak/hexcasting/common/loot/HexLootHandler.java index e0788d5446..b447c05e69 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/loot/HexLootHandler.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/loot/HexLootHandler.java @@ -47,18 +47,18 @@ public class HexLootHandler { new ScrollInjection(new ResourceLocation("minecraft", "chests/stronghold_library"), 5) ); - public static final ImmutableList DEFAULT_LORE_INJECTS = ImmutableList.of( - new ResourceLocation("minecraft", "chests/simple_dungeon"), - new ResourceLocation("minecraft", "chests/abandoned_mineshaft"), - new ResourceLocation("minecraft", "chests/pillager_outpost"), - new ResourceLocation("minecraft", "chests/woodland_mansion"), - new ResourceLocation("minecraft", "chests/stronghold_library"), - // >:) - new ResourceLocation("minecraft", "chests/village/village_desert_house"), - new ResourceLocation("minecraft", "chests/village/village_plains_house"), - new ResourceLocation("minecraft", "chests/village/village_savanna_house"), - new ResourceLocation("minecraft", "chests/village/village_snowy_house"), - new ResourceLocation("minecraft", "chests/village/village_taiga_house") + public static final ImmutableList DEFAULT_LORE_INJECTS = ImmutableList.of( + "minecraft:chests/simple_dungeon", + "minecraft:chests/abandoned_mineshaft", + "minecraft:chests/pillager_outpost", + "minecraft:chests/woodland_mansion", + "minecraft:chests/stronghold_library", + // >:3 + "minecraft:chests/village/village_desert_house", + "minecraft:chests/village/village_plains_house", + "minecraft:chests/village/village_savanna_house", + "minecraft:chests/village/village_snowy_house", + "minecraft:chests/village/village_taiga_house" ); public static int getScrollCount(int range, RandomSource random) { 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..3f0d8543d5 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java @@ -20,7 +20,7 @@ import java.util.List; -import static at.petrak.hexcasting.api.mod.HexConfig.anyMatchResLoc; +import static at.petrak.hexcasting.api.mod.HexConfig.anyMatch; import static at.petrak.hexcasting.api.mod.HexConfig.noneMatch; @Config(name = HexAPI.MOD_ID) @@ -192,7 +192,7 @@ 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 loreInjections = HexLootHandler.DEFAULT_LORE_INJECTS; @ConfigEntry.Gui.Tooltip private double loreChance = HexLootHandler.DEFAULT_LORE_CHANCE; @@ -266,7 +266,7 @@ public int scrollRangeForLootTable(ResourceLocation lootTable) { } public boolean shouldInjectLore(ResourceLocation lootTable) { - return anyMatchResLoc(this.loreInjections, lootTable); + return anyMatch(this.loreInjections, lootTable); } public double getLoreChance() { diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/ForgeHexLootModGen.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/ForgeHexLootModGen.java index d1a85e93e7..338bf4a533 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/ForgeHexLootModGen.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/ForgeHexLootModGen.java @@ -6,6 +6,7 @@ import at.petrak.hexcasting.forge.loot.ForgeHexLoreLootMod; import at.petrak.hexcasting.forge.loot.ForgeHexScrollLootMod; import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import net.minecraftforge.common.data.GlobalLootModifierProvider; @@ -26,9 +27,9 @@ protected void start() { } for (var injection : HexLootHandler.DEFAULT_LORE_INJECTS) { - var name = "lore/%s/%s".formatted(injection.getNamespace(), injection.getPath()); + var name = "lore/%s".formatted(injection.replace(':', '/')); add(name, new ForgeHexLoreLootMod(new LootItemCondition[]{ - LootTableIdCondition.builder(injection).build(), + LootTableIdCondition.builder(new ResourceLocation(injection)).build(), }, HexLootHandler.DEFAULT_LORE_CHANCE)); }