Add an ore to the biome test mod (#3721)

This commit is contained in:
modmuss 2024-04-20 11:28:32 +01:00 committed by GitHub
parent 7ba3e3b760
commit 7f0e1106e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 72 additions and 3 deletions

View file

@ -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"
}
}
]
}
}

View file

@ -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
}
}
}
]
}

View file

@ -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<ConfiguredFeature<?, ?>> COMMON_ORE = RegistryKey.of(
RegistryKeys.CONFIGURED_FEATURE,
new Identifier(FabricBiomeTest.MOD_ID, "common_ore")
);
public static final RegistryKey<PlacedFeature> 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<ConfiguredFeature<?, ?>> 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<PlacedFeature> 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
)
);
}
}

View file

@ -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

View file

@ -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