mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
Add an ore to the biome test mod (#3721)
This commit is contained in:
parent
7ba3e3b760
commit
7f0e1106e7
5 changed files with 72 additions and 3 deletions
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -16,19 +16,26 @@
|
||||||
|
|
||||||
package net.fabricmc.fabric.test.biome;
|
package net.fabricmc.fabric.test.biome;
|
||||||
|
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.registry.Registerable;
|
import net.minecraft.registry.Registerable;
|
||||||
import net.minecraft.registry.RegistryBuilder;
|
import net.minecraft.registry.RegistryBuilder;
|
||||||
import net.minecraft.registry.RegistryEntryLookup;
|
import net.minecraft.registry.RegistryEntryLookup;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.registry.entry.RegistryEntry;
|
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.util.Identifier;
|
||||||
|
import net.minecraft.world.gen.YOffset;
|
||||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
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.PlacedFeature;
|
||||||
import net.minecraft.world.gen.feature.PlacedFeatures;
|
import net.minecraft.world.gen.feature.PlacedFeatures;
|
||||||
import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier;
|
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.minecraft.world.gen.placementmodifier.SquarePlacementModifier;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||||
|
@ -42,6 +49,14 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen.
|
||||||
RegistryKeys.PLACED_FEATURE,
|
RegistryKeys.PLACED_FEATURE,
|
||||||
new Identifier(FabricBiomeTest.MOD_ID, "fab_desert_well")
|
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
|
@Override
|
||||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||||
|
@ -59,6 +74,9 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen.
|
||||||
|
|
||||||
private void bootstrapConfiguredFeatures(Registerable<ConfiguredFeature<?, ?>> registerable) {
|
private void bootstrapConfiguredFeatures(Registerable<ConfiguredFeature<?, ?>> registerable) {
|
||||||
ConfiguredFeatures.register(registerable, COMMON_DESERT_WELL, Feature.DESERT_WELL);
|
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) {
|
private void bootstrapPlacedFeatures(Registerable<PlacedFeature> registerable) {
|
||||||
|
@ -71,5 +89,13 @@ public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen.
|
||||||
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
|
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
|
||||||
BiomePlacementModifier.of()
|
BiomePlacementModifier.of()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
PlacedFeatures.register(registerable, PLACED_COMMON_ORE, configuredFeatures.getOrThrow(COMMON_ORE),
|
||||||
|
CountPlacementModifier.of(25),
|
||||||
|
HeightRangePlacementModifier.uniform(
|
||||||
|
YOffset.BOTTOM,
|
||||||
|
YOffset.TOP
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package net.fabricmc.fabric.test.biome;
|
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_DESERT_WELL;
|
||||||
|
import static net.fabricmc.fabric.test.biome.DataGeneratorEntrypoint.PLACED_COMMON_ORE;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
|
@ -78,7 +79,10 @@ public class FabricBiomeTest implements ModInitializer {
|
||||||
})
|
})
|
||||||
.add(ModificationPhase.ADDITIONS,
|
.add(ModificationPhase.ADDITIONS,
|
||||||
BiomeSelectors.tag(TagKey.of(RegistryKeys.BIOME, new Identifier(MOD_ID, "tag_selector_test"))),
|
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
|
// Make sure data packs can define dynamic registry contents
|
||||||
// See #2225, #2261
|
// See #2225, #2261
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class WorldgenProvider extends FabricDynamicRegistryProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
|
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
|
||||||
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.BIOME));
|
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.BIOME));
|
||||||
entries.add(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE), DataGeneratorEntrypoint.COMMON_DESERT_WELL);
|
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE));
|
||||||
entries.add(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE), DataGeneratorEntrypoint.PLACED_COMMON_DESERT_WELL);
|
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue