diff --git a/src/main/java/electroblob/wizardry/registry/WizardryLoot.java b/src/main/java/electroblob/wizardry/registry/WizardryLoot.java index 40f8ac38..31ce496a 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryLoot.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryLoot.java @@ -1,6 +1,7 @@ package electroblob.wizardry.registry; import electroblob.wizardry.Wizardry; +import electroblob.wizardry.constants.Element; import electroblob.wizardry.loot.RandomSpell; import electroblob.wizardry.loot.WizardSpell; import net.minecraft.entity.EnumCreatureType; @@ -28,7 +29,9 @@ public final class WizardryLoot { //public static final String FROM_SPAWNER_NBT_FLAG = "fromSpawner"; - public static final ResourceLocation RUINED_SPELL_BOOK_LOOT_TABLE = new ResourceLocation(Wizardry.MODID, "gameplay/imbuement_altar/ruined_spell_book"); + public static final ResourceLocation[] RUINED_SPELL_BOOK_LOOT_TABLES = Arrays.stream(Element.values()).map(e -> + new ResourceLocation(Wizardry.MODID, "gameplay/imbuement_altar/ruined_spell_book_" + e.getName())) + .toArray(ResourceLocation[]::new); private WizardryLoot(){} // No instances! @@ -71,7 +74,7 @@ public final class WizardryLoot { LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/mob_additions")); LootTableList.register(new ResourceLocation(Wizardry.MODID, "gameplay/fishing/junk_additions")); LootTableList.register(new ResourceLocation(Wizardry.MODID, "gameplay/fishing/treasure_additions")); - LootTableList.register(RUINED_SPELL_BOOK_LOOT_TABLE); + for(ResourceLocation location : RUINED_SPELL_BOOK_LOOT_TABLES) LootTableList.register(location); } diff --git a/src/main/java/electroblob/wizardry/tileentity/TileEntityImbuementAltar.java b/src/main/java/electroblob/wizardry/tileentity/TileEntityImbuementAltar.java index b101bd11..a2a4741f 100644 --- a/src/main/java/electroblob/wizardry/tileentity/TileEntityImbuementAltar.java +++ b/src/main/java/electroblob/wizardry/tileentity/TileEntityImbuementAltar.java @@ -259,7 +259,14 @@ public class TileEntityImbuementAltar extends TileEntity implements ITickable { if(fullLootGen){ - LootTable table = world.getLootTableManager().getLootTableFromLocation(WizardryLoot.RUINED_SPELL_BOOK_LOOT_TABLE); + // Pick a random element out of the receptacles and use its loot table + // This is an elegant way of having the dust elements affect the spell outcome without hardcoding + // any actual numbers, thus allowing packmakers as much control as possible over the weighting + // The probabilities are a little complicated but work out quite nicely at 57% chance with 4 of the + // same element of spectral dust + Element element = receptacleElements[world.rand.nextInt(receptacleElements.length)]; + LootTable table = world.getLootTableManager().getLootTableFromLocation( + WizardryLoot.RUINED_SPELL_BOOK_LOOT_TABLES[element.ordinal() - 1]); LootContext context = new LootContext.Builder((WorldServer)world).withPlayer(lastUser) .withLuck(lastUser == null ? 0 : lastUser.getLuck()).build(); diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book.json deleted file mode 100644 index 8bf91073..00000000 --- a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "pools": [ - { - "name": "spell_book", - "rolls": 1, - "entries": [ - { - "type": "item", - "name": "ebwizardry:spell_book", - "weight": 1, - "functions": [ - { - "function": "ebwizardry:random_spell", - "undiscovered_bias": 0.3 - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_earth.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_earth.json new file mode 100644 index 00000000..35e46748 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_earth.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "earth" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_fire.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_fire.json new file mode 100644 index 00000000..9958e489 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_fire.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "fire" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_healing.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_healing.json new file mode 100644 index 00000000..ba777303 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_healing.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "healing" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_ice.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_ice.json new file mode 100644 index 00000000..e1b1039c --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_ice.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "ice" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_lightning.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_lightning.json new file mode 100644 index 00000000..70cd9669 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_lightning.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "lightning" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_necromancy.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_necromancy.json new file mode 100644 index 00000000..36ebf4d7 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_necromancy.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "necromancy" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_sorcery.json b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_sorcery.json new file mode 100644 index 00000000..5930bb69 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/loot_tables/gameplay/imbuement_altar/ruined_spell_book_sorcery.json @@ -0,0 +1,40 @@ +{ + "pools": [ + { + "name": "spell_book", + "rolls": 1, + "entries": [ + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "elements": [ + "sorcery" + ], + "undiscovered_bias": 0.3 + } + ] + }, + { + "type": "item", + "name": "ebwizardry:spell_book", + "weight": 1, + "functions": [ + { + "function": "ebwizardry:random_spell", + "tiers": [ + "novice", + "apprentice", + "advanced" + ], + "undiscovered_bias": 0.3 + } + ] + } + ] + } + ] +} \ No newline at end of file