From 3e60b638a46eb87168e030e94a5020356449ec10 Mon Sep 17 00:00:00 2001 From: PinkGoosik Date: Mon, 25 Dec 2023 17:02:55 +0500 Subject: [PATCH] enable crystal generation --- .../registry/ArtifalityFeatures.java | 38 ++++++++----------- .../worldgen/configured_feature/crystals.json | 4 ++ .../worldgen/placed_feature/crystals.json | 4 ++ 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 src/main/resources/data/artifality/worldgen/configured_feature/crystals.json create mode 100644 src/main/resources/data/artifality/worldgen/placed_feature/crystals.json diff --git a/src/main/java/artifality/registry/ArtifalityFeatures.java b/src/main/java/artifality/registry/ArtifalityFeatures.java index 3cce1f1..9b82583 100644 --- a/src/main/java/artifality/registry/ArtifalityFeatures.java +++ b/src/main/java/artifality/registry/ArtifalityFeatures.java @@ -1,32 +1,26 @@ package artifality.registry; -import static artifality.ArtifalityMod.id; - +import artifality.ArtifalityMod; import artifality.worldgen.feature.CrystalFeature; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; - -import java.util.List; +import net.fabricmc.fabric.api.biome.v1.ModificationPhase; +import net.minecraft.registry.*; +import net.minecraft.registry.tag.BiomeTags; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.feature.*; -@SuppressWarnings("deprecation") public class ArtifalityFeatures { -// public static final Feature CRYSTAL_FEATURE = new CrystalFeature(); -// public static final ConfiguredFeature CRYSTAL_FEATURE_CONFIG = new ConfiguredFeature<>(CRYSTAL_FEATURE, new DefaultFeatureConfig()); -// public static final PlacedFeature CRYSTAL_FEATURE_PLACED = new PlacedFeature(Holder.createDirect(CRYSTAL_FEATURE_CONFIG), List.of(PlacedFeatureUtil.BOTTOM_TO_MAX_TERRAIN_HEIGHT_RANGE)); + public static final Feature CRYSTAL_FEATURE = new CrystalFeature(); + public static final RegistryKey> CRYSTAL_FEATURE_CONFIG = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, ArtifalityMod.id("crystals")); + public static final RegistryKey CRYSTAL_FEATURE_PLACED = RegistryKey.of(RegistryKeys.PLACED_FEATURE, ArtifalityMod.id("crystals")); public static void init() { -// Registry.register(Registries.FEATURE, id("crystal_feature"), CRYSTAL_FEATURE); -// Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id("crystal_feature"), CRYSTAL_FEATURE_CONFIG); -// Registry.register(BuiltinRegistries.PLACED_FEATURE, id("crystal_feature"), CRYSTAL_FEATURE_PLACED); -// -// BiomeModifications.addFeature( -// ctx -> { -// Biome.Category category = Biome.getCategory(ctx.getBiomeRegistryEntry()); -// return !category.equals(Biome.Category.NETHER) && !category.equals(Biome.Category.THEEND); -// }, -// GenerationStep.Feature.UNDERGROUND_DECORATION, -// BuiltinRegistries.PLACED_FEATURE.getKey(CRYSTAL_FEATURE_PLACED).orElseThrow() -// ); + Registry.register(Registries.FEATURE, ArtifalityMod.id("crystals"), CRYSTAL_FEATURE); + + BiomeModifications.create(ArtifalityMod.id("features")) + .add(ModificationPhase.ADDITIONS, ctx -> { + var entry = ctx.getBiomeRegistryEntry(); + return !entry.isIn(BiomeTags.IS_NETHER) && !entry.isIn(BiomeTags.IS_END); + }, ctx -> ctx.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_DECORATION, CRYSTAL_FEATURE_PLACED)); } } diff --git a/src/main/resources/data/artifality/worldgen/configured_feature/crystals.json b/src/main/resources/data/artifality/worldgen/configured_feature/crystals.json new file mode 100644 index 0000000..7a7f7df --- /dev/null +++ b/src/main/resources/data/artifality/worldgen/configured_feature/crystals.json @@ -0,0 +1,4 @@ +{ + "type": "artifality:crystals", + "config": {} +} \ No newline at end of file diff --git a/src/main/resources/data/artifality/worldgen/placed_feature/crystals.json b/src/main/resources/data/artifality/worldgen/placed_feature/crystals.json new file mode 100644 index 0000000..e7855b0 --- /dev/null +++ b/src/main/resources/data/artifality/worldgen/placed_feature/crystals.json @@ -0,0 +1,4 @@ +{ + "feature": "artifality:crystals", + "placement": [] +} \ No newline at end of file