diff --git a/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java index a5715e2fac..5812d7dc76 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java @@ -10,11 +10,19 @@ import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.world.damagesource.DamageEffects; +import net.minecraft.world.damagesource.DamageScaling; +import net.minecraft.world.damagesource.DamageType; import vazkii.botania.data.*; import vazkii.botania.data.recipes.*; +import static vazkii.botania.common.BotaniaDamageTypes.*; + public class FabricDatagenInitializer implements DataGeneratorEntrypoint { @Override public void onInitializeDataGenerator(FabricDataGenerator generator) { @@ -40,7 +48,8 @@ private static void configureXplatDatagen(FabricDataGenerator.Pack pack) { pack.addProvider(EntityTagProvider::new); pack.addProvider(BannerPatternTagsProvider::new); pack.addProvider(BiomeTagProvider::new); - // pack.addProvider(DamageTypeTagProvider::new); + pack.addProvider(FabricDynamicProvider::new); + pack.addProvider(DamageTypeTagProvider::new); pack.addProvider((PackOutput output) -> new StonecuttingProvider(output)); pack.addProvider((PackOutput output) -> new CraftingRecipeProvider(output)); pack.addProvider((PackOutput output) -> new SmeltingProvider(output)); @@ -58,4 +67,15 @@ private static void configureXplatDatagen(FabricDataGenerator.Pack pack) { pack.addProvider((PackOutput output) -> new PottedPlantModelProvider(output)); pack.addProvider(AdvancementProvider::create); } + + @Override + public void buildRegistry(RegistrySetBuilder builder) { + builder.add(Registries.DAMAGE_TYPE, FabricDatagenInitializer::damageTypeBC); + } + + protected static void damageTypeBC(BootstapContext context) { + context.register(RELIC_DAMAGE, new DamageType("botania-relic", DamageScaling.NEVER, 1F, DamageEffects.FREEZING)); + context.register(PLAYER_ATTACK_ARMOR_PIERCING, new DamageType("player", DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER, 0.1F)); + context.register(KEY_EXPLOSION, new DamageType("botania.key_explosion", DamageScaling.ALWAYS, 0.1F)); + } } diff --git a/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDynamicProvider.java b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDynamicProvider.java new file mode 100644 index 0000000000..f788e271c2 --- /dev/null +++ b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDynamicProvider.java @@ -0,0 +1,34 @@ +package vazkii.botania.fabric.data; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; +import net.minecraft.tags.DamageTypeTags; +import net.minecraft.world.damagesource.DamageEffects; +import net.minecraft.world.damagesource.DamageScaling; +import net.minecraft.world.damagesource.DamageType; +import net.minecraft.world.damagesource.DamageTypes; + +import java.util.concurrent.CompletableFuture; + +import static vazkii.botania.common.BotaniaDamageTypes.*; + +public class FabricDynamicProvider extends FabricDynamicRegistryProvider { + + public FabricDynamicProvider(FabricDataOutput output, CompletableFuture registriesFuture) { + super(output, registriesFuture); + } + + @Override + protected void configure(HolderLookup.Provider registries, Entries entries) { + entries.add(RELIC_DAMAGE, new DamageType("botania-relic", DamageScaling.NEVER, 1F, DamageEffects.FREEZING)); + entries.add(PLAYER_ATTACK_ARMOR_PIERCING, new DamageType("player", DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER, 0.1F)); + entries.add(KEY_EXPLOSION, new DamageType("botania.key_explosion", DamageScaling.ALWAYS, 0.1F)); + } + + @Override + public String getName() { + return "damageTypes"; + } +} diff --git a/Xplat/src/generated/resources/.cache/63808f53e60950986e6584ea7d4809e9f3529082 b/Xplat/src/generated/resources/.cache/63808f53e60950986e6584ea7d4809e9f3529082 new file mode 100644 index 0000000000..79c6a1388b --- /dev/null +++ b/Xplat/src/generated/resources/.cache/63808f53e60950986e6584ea7d4809e9f3529082 @@ -0,0 +1,4 @@ +// 1.20.1 Botania/damageTypes +f4d7070676cbf1c0c64369ebd632f197d21740e8 data/botania/damage_type/key_explosion.json +4b4b2ff422d23e4cb6282f664d89dad7ac8ff8e6 data/botania/damage_type/player_attack_armor_piercing.json +e86480f14b86be48b6ca82b6a7e7f9b8037389c9 data/botania/damage_type/relic_damage.json diff --git a/Xplat/src/generated/resources/.cache/f2d566d627d9eb6ae3bc5d051faf4e5c9e17d559 b/Xplat/src/generated/resources/.cache/f2d566d627d9eb6ae3bc5d051faf4e5c9e17d559 new file mode 100644 index 0000000000..8972b81b5e --- /dev/null +++ b/Xplat/src/generated/resources/.cache/f2d566d627d9eb6ae3bc5d051faf4e5c9e17d559 @@ -0,0 +1,8 @@ +// 1.20.1 Botania/Tags for minecraft:damage_type +14aff817ac86d16f5a0a2599f4bb6bde25bfc7da data/botania/tags/damage_type/ring_of_odin_immune.json +de7c8ce81aa7f5e90670e58c2202565cf5473485 data/minecraft/tags/damage_type/bypasses_armor.json +24c644d92fd6641021b615151b60869274f2efe4 data/minecraft/tags/damage_type/bypasses_effects.json +24c644d92fd6641021b615151b60869274f2efe4 data/minecraft/tags/damage_type/bypasses_enchantments.json +24c644d92fd6641021b615151b60869274f2efe4 data/minecraft/tags/damage_type/bypasses_resistance.json +7de1fa9cdf22a6a4989abe92d268ba2ec44fd14e data/minecraft/tags/damage_type/is_explosion.json +24c644d92fd6641021b615151b60869274f2efe4 data/minecraft/tags/damage_type/no_impact.json diff --git a/Xplat/src/generated/resources/data/botania/damage_type/key_explosion.json b/Xplat/src/generated/resources/data/botania/damage_type/key_explosion.json new file mode 100644 index 0000000000..8b0d19da02 --- /dev/null +++ b/Xplat/src/generated/resources/data/botania/damage_type/key_explosion.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "botania.key_explosion", + "scaling": "always" +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/botania/damage_type/player_attack_armor_piercing.json b/Xplat/src/generated/resources/data/botania/damage_type/player_attack_armor_piercing.json new file mode 100644 index 0000000000..674995e142 --- /dev/null +++ b/Xplat/src/generated/resources/data/botania/damage_type/player_attack_armor_piercing.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "player", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/botania/damage_type/relic_damage.json b/Xplat/src/generated/resources/data/botania/damage_type/relic_damage.json new file mode 100644 index 0000000000..cc90a5ec94 --- /dev/null +++ b/Xplat/src/generated/resources/data/botania/damage_type/relic_damage.json @@ -0,0 +1,6 @@ +{ + "effects": "freezing", + "exhaustion": 1.0, + "message_id": "botania-relic", + "scaling": "never" +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/botania/tags/damage_type/ring_of_odin_immune.json b/Xplat/src/generated/resources/data/botania/tags/damage_type/ring_of_odin_immune.json new file mode 100644 index 0000000000..9970d3cb3d --- /dev/null +++ b/Xplat/src/generated/resources/data/botania/tags/damage_type/ring_of_odin_immune.json @@ -0,0 +1,14 @@ +{ + "replace": false, + "values": [ + "minecraft:drown", + "minecraft:fall", + "minecraft:in_wall", + "minecraft:starve", + "minecraft:fly_into_wall", + { + "id": "#minecraft:is_fire", + "required": false + } + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_armor.json new file mode 100644 index 0000000000..d3fbe8c014 --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "botania:player_attack_armor_piercing", + "botania:relic_damage" + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_effects.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_effects.json new file mode 100644 index 0000000000..6e778eca4f --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_effects.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "botania:relic_damage" + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json new file mode 100644 index 0000000000..6e778eca4f --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "botania:relic_damage" + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_resistance.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_resistance.json new file mode 100644 index 0000000000..6e778eca4f --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/bypasses_resistance.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "botania:relic_damage" + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/is_explosion.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/is_explosion.json new file mode 100644 index 0000000000..8f29c6f401 --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/is_explosion.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "botania:key_explosion" + ] +} \ No newline at end of file diff --git a/Xplat/src/generated/resources/data/minecraft/tags/damage_type/no_impact.json b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/no_impact.json new file mode 100644 index 0000000000..6e778eca4f --- /dev/null +++ b/Xplat/src/generated/resources/data/minecraft/tags/damage_type/no_impact.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "botania:relic_damage" + ] +} \ No newline at end of file diff --git a/Xplat/src/main/java/vazkii/botania/data/DamageTypeTagProvider.java b/Xplat/src/main/java/vazkii/botania/data/DamageTypeTagProvider.java index 5011cff12a..bcffe13867 100644 --- a/Xplat/src/main/java/vazkii/botania/data/DamageTypeTagProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/DamageTypeTagProvider.java @@ -15,7 +15,6 @@ import java.util.concurrent.CompletableFuture; -// Unused currently. Crashes on tag gen because it can't find botania's damage types, as they're not registered yet. public class DamageTypeTagProvider extends TagsProvider { public DamageTypeTagProvider(PackOutput packOutput, CompletableFuture lookupProvider) { @@ -24,14 +23,18 @@ public DamageTypeTagProvider(PackOutput packOutput, CompletableFuture