More work towards 22w42a

This commit is contained in:
shedaniel
2022-10-22 17:45:51 +08:00
parent 5c10baf55f
commit 2b423ae433
9 changed files with 79 additions and 32 deletions

View File

@@ -22,33 +22,20 @@ package dev.architectury.test.worldgen;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.registry.level.biome.BiomeModifications;
import dev.architectury.test.TestMod;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.features.FeatureUtils;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.placement.*;
import java.util.List;
public class TestWorldGeneration {
public static void initialize() {
LifecycleEvent.SETUP.register(() -> {
Holder<ConfiguredFeature<OreConfiguration, ?>> configuredFeature = FeatureUtils.register(TestMod.MOD_ID + ":diamond_blocks", Feature.ORE,
new OreConfiguration(OreFeatures.NATURAL_STONE, Blocks.DIAMOND_BLOCK.defaultBlockState(), 33));
Holder<PlacedFeature> placedFeature = PlacementUtils.register(TestMod.MOD_ID + ":diamond_blocks", configuredFeature,
List.of(CountPlacement.of(4), InSquarePlacement.spread(),
HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(15)),
BiomeFilter.biome()));
BiomeModifications.addProperties((ctx, mutable) -> {
if (ctx.hasTag(BiomeTags.IS_FOREST)) {
mutable.getGenerationProperties().addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION, placedFeature);
mutable.getGenerationProperties().addFeature(GenerationStep.Decoration.TOP_LAYER_MODIFICATION,
ResourceKey.create(Registry.PLACED_FEATURE_REGISTRY,
new ResourceLocation(TestMod.MOD_ID + ":diamond_blocks")));
}
});
});

View File

@@ -0,0 +1,18 @@
{
"type" : "minecraft:ore",
"config" : {
"discard_chance_on_air_exposure" : 0.0,
"size" : 33,
"targets" : [
{
"state" : {
"Name" : "minecraft:diamond_block"
},
"target" : {
"predicate_type" : "minecraft:tag_match",
"tag" : "minecraft:base_stone_overworld"
}
}
]
}
}

View File

@@ -0,0 +1,24 @@
{
"feature" : "architectury_test:diamond_blocks",
"placement" : [
{
"count" : 4,
"type" : "minecraft:count"
}, {
"type" : "minecraft:in_square"
}, {
"height" : {
"min_inclusive" : {
"above_bottom" : 0
},
"max_inclusive" : {
"absolute" : 15
},
"type" : "minecraft:uniform"
},
"type" : "minecraft:height_range"
}, {
"type" : "minecraft:biome"
}
]
}