Skip to content

Commit

Permalink
Add an ore to the biome test mod (#3721)
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Apr 20, 2024
1 parent 7ba3e3b commit 7f0e110
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -59,6 +74,9 @@ public void buildRegistry(RegistryBuilder registryBuilder) {

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) {
Expand All @@ -71,5 +89,13 @@ private void bootstrapPlacedFeatures(Registerable<PlacedFeature> registerable) {
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
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -78,7 +79,10 @@ public void onInitialize() {
})
.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public WorldgenProvider(FabricDataOutput output, CompletableFuture<RegistryWrapp
@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
Expand Down

0 comments on commit 7f0e110

Please sign in to comment.