diff --git a/src/main/generated/data/arcanuscontinuum/loot_tables/bookshelves/wizard_tower.json b/src/main/generated/data/arcanuscontinuum/loot_tables/bookshelves/wizard_tower.json index db08aca..7b0144f 100644 --- a/src/main/generated/data/arcanuscontinuum/loot_tables/bookshelves/wizard_tower.json +++ b/src/main/generated/data/arcanuscontinuum/loot_tables/bookshelves/wizard_tower.json @@ -18,7 +18,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:heal_effect\"],Positions:[{X:82,Y:83},{X:146,Y:81}],Shape:\"arcanuscontinuum:self_shape\"}],Name:\"Heal Self\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:heal_effect\"],Positions:[{X:82,Y:83},{X:146,Y:81}],Shape:\"arcanuscontinuum:self_shape\"}],Name:\"Heal Self\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -34,7 +34,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\"],Positions:[{X:80,Y:84},{X:133,Y:48},{X:139,Y:118}],Shape:\"arcanuscontinuum:missile_shape\"}],Name:\"Heal Ally\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\"],Positions:[{X:80,Y:84},{X:133,Y:48},{X:139,Y:118}],Shape:\"arcanuscontinuum:missile_shape\"}],Name:\"Heal Ally\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -50,7 +50,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:mana_shield_effect\"],Positions:[{X:119,Y:40},{X:172,Y:68}],Shape:\"arcanuscontinuum:self_shape\"},{Effects:[\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\"],Positions:[{X:146,Y:120},{X:94,Y:133},{X:67,Y:76},{X:120,Y:85}],Shape:\"arcanuscontinuum:aoe_shape\"}],Name:\"Paladin's Shield\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:mana_shield_effect\"],Positions:[{X:119,Y:40},{X:172,Y:68}],Shape:\"arcanuscontinuum:self_shape\"},{Effects:[\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\",\"arcanuscontinuum:heal_effect\"],Positions:[{X:146,Y:120},{X:94,Y:133},{X:67,Y:76},{X:120,Y:85}],Shape:\"arcanuscontinuum:aoe_shape\"}],Name:\"Paladin's Shield\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -66,7 +66,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:fire_effect\"],Positions:[{X:118,Y:81},{X:116,Y:36},{X:71,Y:82},{X:118,Y:129},{X:169,Y:81}],Shape:\"arcanuscontinuum:lob_shape\"}],Name:\"Fireball\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:fire_effect\"],Positions:[{X:118,Y:81},{X:116,Y:36},{X:71,Y:82},{X:118,Y:129},{X:169,Y:81}],Shape:\"arcanuscontinuum:lob_shape\"}],Name:\"Fireball\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -82,7 +82,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\"],Positions:[{X:86,Y:82},{X:146,Y:81},{X:117,Y:127}],Shape:\"arcanuscontinuum:missile_shape\"}],Name:\"Magic Missile\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\"],Positions:[{X:86,Y:82},{X:146,Y:81},{X:117,Y:127}],Shape:\"arcanuscontinuum:missile_shape\"}],Name:\"Magic Missile\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -98,7 +98,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\"],Positions:[{X:117,Y:46},{X:173,Y:73},{X:144,Y:128},{X:77,Y:124},{X:60,Y:65}],Shape:\"arcanuscontinuum:smite_shape\"},{Effects:[],Positions:[{X:117,Y:91}],Shape:\"arcanuscontinuum:burst_shape\"}],Name:\"Smite\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\",\"arcanuscontinuum:damage_effect\"],Positions:[{X:117,Y:46},{X:173,Y:73},{X:144,Y:128},{X:77,Y:124},{X:60,Y:65}],Shape:\"arcanuscontinuum:smite_shape\"},{Effects:[],Positions:[{X:117,Y:91}],Shape:\"arcanuscontinuum:burst_shape\"}],Name:\"Smite\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -114,7 +114,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:teleport_effect\",\"arcanuscontinuum:teleport_effect\",\"arcanuscontinuum:teleport_effect\"],Positions:[{X:119,Y:50},{X:159,Y:98},{X:116,Y:135},{X:79,Y:92}],Shape:\"arcanuscontinuum:bolt_shape\"}],Name:\"Blink\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:teleport_effect\",\"arcanuscontinuum:teleport_effect\",\"arcanuscontinuum:teleport_effect\"],Positions:[{X:119,Y:50},{X:159,Y:98},{X:116,Y:135},{X:79,Y:92}],Shape:\"arcanuscontinuum:bolt_shape\"}],Name:\"Blink\"}}" } ], "name": "arcanuscontinuum:spell_book" @@ -130,7 +130,7 @@ "functions": [ { "function": "minecraft:set_nbt", - "tag": "{ComponentGroups:[{Effects:[\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\"],Positions:[{X:121,Y:41},{X:168,Y:88},{X:115,Y:134},{X:69,Y:84},{X:118,Y:85}],Shape:\"arcanuscontinuum:self_shape\"}],Name:\"Zoomies\"}" + "tag": "{Spell:{ComponentGroups:[{Effects:[\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\",\"arcanuscontinuum:speed_effect\"],Positions:[{X:121,Y:41},{X:168,Y:88},{X:115,Y:134},{X:69,Y:84},{X:118,Y:85}],Shape:\"arcanuscontinuum:self_shape\"}],Name:\"Zoomies\"}}" } ], "name": "arcanuscontinuum:spell_book" diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/datagen/common/ArcanusChestLootProvider.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/datagen/common/ArcanusChestLootProvider.java index 6b30c69..a80c58a 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/datagen/common/ArcanusChestLootProvider.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/datagen/common/ArcanusChestLootProvider.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootTableReference; import net.minecraft.world.level.storage.loot.functions.EnchantWithLevelsFunction; +import net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction; import net.minecraft.world.level.storage.loot.functions.SetNbtFunction; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; @@ -26,6 +27,7 @@ import java.util.List; import java.util.function.BiConsumer; +import java.util.function.Supplier; public class ArcanusChestLootProvider extends SimpleFabricLootTableProvider { @@ -41,28 +43,28 @@ public void generate(BiConsumer output) { .setRolls(UniformGenerator.between(0, 6)) .add(AlternativesEntry.alternatives( LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(healSelfSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::healSelfSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(healAllySpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::healAllySpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(paladinsShieldSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::paladinsShieldSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(fireballSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::fireballSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(magicMissileSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::magicMissileSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(smiteSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::smiteSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(blinkSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::blinkSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)), LootItem.lootTableItem(ArcanusItems.SPELL_BOOK.get()) - .apply(SetNbtFunction.setTag(zoomiesSpell())) + .apply(setSpellNbt(ArcanusChestLootProvider::zoomiesSpell)) .when(LootItemRandomChanceCondition.randomChance(0.25F)) )) .add(LootItem.lootTableItem(Items.WRITABLE_BOOK).setWeight(5)) @@ -76,49 +78,47 @@ public void generate(BiConsumer output) { ); } - private static CompoundTag healSelfSpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.SELF.get(), List.of(ArcanusSpellComponents.HEAL.get()), List.of(new Vector2i(82, 83), new Vector2i(146, 81)))), "Heal Self"); - return spell.toNbt(); + public static LootItemConditionalFunction.Builder setSpellNbt(Supplier spell) { + var outerTag = new CompoundTag(); + outerTag.put("Spell", spell.get().toNbt()); + return SetNbtFunction.setTag(outerTag); } - private static CompoundTag healAllySpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.MISSILE.get(), List.of(ArcanusSpellComponents.HEAL.get(), ArcanusSpellComponents.HEAL.get()), List.of(new Vector2i(80, 84), new Vector2i(133, 48), new Vector2i(139, 118)))), "Heal Ally"); - return spell.toNbt(); + private static Spell healSelfSpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.SELF.get(), List.of(ArcanusSpellComponents.HEAL.get()), List.of(new Vector2i(82, 83), new Vector2i(146, 81)))), "Heal Self"); } - private static CompoundTag paladinsShieldSpell() { - var spell = new Spell(List.of( + private static Spell healAllySpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.MISSILE.get(), List.of(ArcanusSpellComponents.HEAL.get(), ArcanusSpellComponents.HEAL.get()), List.of(new Vector2i(80, 84), new Vector2i(133, 48), new Vector2i(139, 118)))), "Heal Ally"); + } + + private static Spell paladinsShieldSpell() { + return new Spell(List.of( new SpellGroup(ArcanusSpellComponents.SELF.get(), List.of(ArcanusSpellComponents.MANA_SHIELD.get()), List.of(new Vector2i(119, 40), new Vector2i(172, 68))), new SpellGroup(ArcanusSpellComponents.AOE.get(), List.of(ArcanusSpellComponents.HEAL.get(), ArcanusSpellComponents.HEAL.get(), ArcanusSpellComponents.HEAL.get()), List.of(new Vector2i(146, 120), new Vector2i(94, 133), new Vector2i(67, 76), new Vector2i(120, 85))) ), "Paladin's Shield"); - return spell.toNbt(); } - private static CompoundTag fireballSpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.LOB.get(), List.of(ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.FIRE.get()), List.of(new Vector2i(118, 81), new Vector2i(116, 36), new Vector2i(71, 82), new Vector2i(118, 129), new Vector2i(169, 81)))), "Fireball"); - return spell.toNbt(); + private static Spell fireballSpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.LOB.get(), List.of(ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.FIRE.get()), List.of(new Vector2i(118, 81), new Vector2i(116, 36), new Vector2i(71, 82), new Vector2i(118, 129), new Vector2i(169, 81)))), "Fireball"); } - private static CompoundTag magicMissileSpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.MISSILE.get(), List.of(ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get()), List.of(new Vector2i(86, 82), new Vector2i(146, 81), new Vector2i(117, 127)))), "Magic Missile"); - return spell.toNbt(); + private static Spell magicMissileSpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.MISSILE.get(), List.of(ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get()), List.of(new Vector2i(86, 82), new Vector2i(146, 81), new Vector2i(117, 127)))), "Magic Missile"); } - private static CompoundTag smiteSpell() { - var spell = new Spell(List.of( + private static Spell smiteSpell() { + return new Spell(List.of( new SpellGroup(ArcanusSpellComponents.SMITE.get(), List.of(ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get(), ArcanusSpellComponents.DAMAGE.get()), List.of(new Vector2i(117, 46), new Vector2i(173, 73), new Vector2i(144, 128), new Vector2i(77, 124), new Vector2i(60, 65))), new SpellGroup(ArcanusSpellComponents.BURST.get(), List.of(), List.of(new Vector2i(117, 91))) ), "Smite"); - return spell.toNbt(); } - private static CompoundTag blinkSpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.BOLT.get(), List.of(ArcanusSpellComponents.TELEPORT.get(), ArcanusSpellComponents.TELEPORT.get(), ArcanusSpellComponents.TELEPORT.get()), List.of(new Vector2i(119, 50), new Vector2i(159, 98), new Vector2i(116, 135), new Vector2i(79, 92)))), "Blink"); - return spell.toNbt(); + private static Spell blinkSpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.BOLT.get(), List.of(ArcanusSpellComponents.TELEPORT.get(), ArcanusSpellComponents.TELEPORT.get(), ArcanusSpellComponents.TELEPORT.get()), List.of(new Vector2i(119, 50), new Vector2i(159, 98), new Vector2i(116, 135), new Vector2i(79, 92)))), "Blink"); } - private static CompoundTag zoomiesSpell() { - var spell = new Spell(List.of(new SpellGroup(ArcanusSpellComponents.SELF.get(), List.of(ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get()), List.of(new Vector2i(121, 41), new Vector2i(168, 88), new Vector2i(115, 134), new Vector2i(69, 84), new Vector2i(118, 85)))), "Zoomies"); - return spell.toNbt(); + private static Spell zoomiesSpell() { + return new Spell(List.of(new SpellGroup(ArcanusSpellComponents.SELF.get(), List.of(ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get(), ArcanusSpellComponents.SPEED.get()), List.of(new Vector2i(121, 41), new Vector2i(168, 88), new Vector2i(115, 134), new Vector2i(69, 84), new Vector2i(118, 85)))), "Zoomies"); } }