diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/common_ore.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/common_ore.json new file mode 100644 index 000000000..63184d95b --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/configured_feature/common_ore.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:ore", + "config": { + "discard_chance_on_air_exposure": 0.0, + "size": 5, + "targets": [ + { + "state": { + "Name": "minecraft:diamond_block" + }, + "target": { + "predicate_type": "minecraft:tag_match", + "tag": "minecraft:stone_ore_replaceables" + } + } + ] + } +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/common_ore.json b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/common_ore.json new file mode 100644 index 000000000..87932a728 --- /dev/null +++ b/fabric-biome-api-v1/src/testmod/generated/data/fabric-biome-api-v1-testmod/worldgen/placed_feature/common_ore.json @@ -0,0 +1,21 @@ +{ + "feature": "fabric-biome-api-v1-testmod:common_ore", + "placement": [ + { + "type": "minecraft:count", + "count": 25 + }, + { + "type": "minecraft:height_range", + "height": { + "type": "minecraft:uniform", + "max_inclusive": { + "below_top": 0 + }, + "min_inclusive": { + "above_bottom": 0 + } + } + } + ] +} \ No newline at end of file diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java index 42b420cd2..11a15c493 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/DataGeneratorEntrypoint.java @@ -16,19 +16,26 @@ package net.fabricmc.fabric.test.biome; +import net.minecraft.block.Blocks; import net.minecraft.registry.Registerable; import net.minecraft.registry.RegistryBuilder; import net.minecraft.registry.RegistryEntryLookup; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.structure.rule.TagMatchRuleTest; import net.minecraft.util.Identifier; +import net.minecraft.world.gen.YOffset; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.PlacedFeatures; import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier; +import net.minecraft.world.gen.placementmodifier.CountPlacementModifier; +import net.minecraft.world.gen.placementmodifier.HeightRangePlacementModifier; import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; @@ -42,6 +49,14 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen. RegistryKeys.PLACED_FEATURE, new Identifier(FabricBiomeTest.MOD_ID, "fab_desert_well") ); + public static final RegistryKey> COMMON_ORE = RegistryKey.of( + RegistryKeys.CONFIGURED_FEATURE, + new Identifier(FabricBiomeTest.MOD_ID, "common_ore") + ); + public static final RegistryKey PLACED_COMMON_ORE = RegistryKey.of( + RegistryKeys.PLACED_FEATURE, + new Identifier(FabricBiomeTest.MOD_ID, "common_ore") + ); @Override public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) { @@ -59,6 +74,9 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen. private void bootstrapConfiguredFeatures(Registerable> registerable) { ConfiguredFeatures.register(registerable, COMMON_DESERT_WELL, Feature.DESERT_WELL); + + OreFeatureConfig featureConfig = new OreFeatureConfig(new TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES), Blocks.DIAMOND_BLOCK.getDefaultState(), 5); + ConfiguredFeatures.register(registerable, COMMON_ORE, Feature.ORE, featureConfig); } private void bootstrapPlacedFeatures(Registerable registerable) { @@ -71,5 +89,13 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen. PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of() ); + + PlacedFeatures.register(registerable, PLACED_COMMON_ORE, configuredFeatures.getOrThrow(COMMON_ORE), + CountPlacementModifier.of(25), + HeightRangePlacementModifier.uniform( + YOffset.BOTTOM, + YOffset.TOP + ) + ); } } diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java index 7acad7e38..3357144df 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java @@ -17,6 +17,7 @@ package net.fabricmc.fabric.test.biome; import static net.fabricmc.fabric.test.biome.DataGeneratorEntrypoint.PLACED_COMMON_DESERT_WELL; +import static net.fabricmc.fabric.test.biome.DataGeneratorEntrypoint.PLACED_COMMON_ORE; import com.google.common.base.Preconditions; @@ -78,7 +79,10 @@ public class FabricBiomeTest implements ModInitializer { }) .add(ModificationPhase.ADDITIONS, BiomeSelectors.tag(TagKey.of(RegistryKeys.BIOME, new Identifier(MOD_ID, "tag_selector_test"))), - context -> context.getEffects().setSkyColor(0x770000)); + context -> context.getEffects().setSkyColor(0x770000)) + .add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInOverworld(), context -> + context.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PLACED_COMMON_ORE) + ); // Make sure data packs can define dynamic registry contents // See #2225, #2261 diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java index 6c0c78875..66072fbef 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/WorldgenProvider.java @@ -32,8 +32,8 @@ public class WorldgenProvider extends FabricDynamicRegistryProvider { @Override protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { entries.addAll(registries.getWrapperOrThrow(RegistryKeys.BIOME)); - entries.add(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE), DataGeneratorEntrypoint.COMMON_DESERT_WELL); - entries.add(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE), DataGeneratorEntrypoint.PLACED_COMMON_DESERT_WELL); + entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE)); + entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE)); } @Override