Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mysticsbiomes.core.init;
- import com.mysticsbiomes.common.block.StrawberryBushBlock;
- import com.mysticsbiomes.core.MysticsBiomes;
- import net.minecraft.core.Holder;
- import net.minecraft.core.Registry;
- import net.minecraft.data.worldgen.features.FeatureUtils;
- import net.minecraft.data.worldgen.placement.PlacementUtils;
- import net.minecraft.data.worldgen.placement.VegetationPlacements;
- import net.minecraft.util.random.SimpleWeightedRandomList;
- import net.minecraft.util.valueproviders.ConstantInt;
- import net.minecraft.util.valueproviders.UniformInt;
- import net.minecraft.world.level.block.Block;
- import net.minecraft.world.level.block.Blocks;
- import net.minecraft.world.level.block.state.BlockState;
- import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
- import net.minecraft.world.level.levelgen.feature.Feature;
- import net.minecraft.world.level.levelgen.feature.configurations.*;
- import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize;
- import net.minecraft.world.level.levelgen.feature.foliageplacers.RandomSpreadFoliagePlacer;
- import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
- import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
- import net.minecraft.world.level.levelgen.feature.trunkplacers.BendingTrunkPlacer;
- import net.minecraft.world.level.levelgen.feature.trunkplacers.FancyTrunkPlacer;
- import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer;
- import net.minecraft.world.level.levelgen.placement.*;
- import net.minecraftforge.registries.DeferredRegister;
- import net.minecraftforge.registries.RegistryObject;
- import java.util.List;
- import java.util.function.Supplier;
- import static net.minecraftforge.registries.DeferredRegister.create;
- public class MysticFeatures {
- public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES = create(Registry.CONFIGURED_FEATURE_REGISTRY, MysticsBiomes.modId);
- public static final DeferredRegister<PlacedFeature> PLACED_FEATURES = create(Registry.PLACED_FEATURE_REGISTRY, MysticsBiomes.modId);
- public static class Configured {
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> JACARANDA_TREE = register("jacaranda_tree", Feature.TREE, () -> (new TreeConfiguration.TreeConfigurationBuilder(BlockStateProvider.simple(MysticBlocks.JACARANDA_LOG.get()), new BendingTrunkPlacer(4, 2, 0, 2, UniformInt.of(1, 1)), new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(MysticBlocks.JACARANDA_BLOSSOMS.get().defaultBlockState(), 2).add(MysticBlocks.JACARANDA_LEAVES.get().defaultBlockState(), 3)), new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(3), 32), new TwoLayersFeatureSize(1, 0, 1))).build());
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> LAVENDER = register("lavender", Feature.RANDOM_PATCH, () -> (new RandomPatchConfiguration(128, 9, 7, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(MysticBlocks.LAVENDER.get()))))));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> GRASS = register("grass", Feature.RANDOM_PATCH, () -> (new RandomPatchConfiguration(222, 7, 7, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(Blocks.GRASS))))));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> LIGHT_GRASS = register("light_grass", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(Blocks.GRASS)), List.of(Blocks.GRASS_BLOCK)));
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> PINK_CHERRY_TREE = register("pink_cherry_tree", Feature.TREE, () -> (createBushyFoliage(MysticBlocks.CHERRY_LOG.get(), MysticBlocks.PINK_CHERRY_BLOSSOMS.get(), 11, 0, 112)).build());
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> LARGE_PINK_CHERRY_TREE = register("large_pink_cherry_tree", Feature.TREE, () -> (createBushyFoliage(MysticBlocks.CHERRY_LOG.get(), MysticBlocks.PINK_CHERRY_BLOSSOMS.get(), 13, 3, 128)).build());
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> WHITE_CHERRY_TREE = register("white_cherry_tree", Feature.TREE, () -> (createBushyFoliage(MysticBlocks.CHERRY_LOG.get(), MysticBlocks.WHITE_CHERRY_BLOSSOMS.get(), 11, 0, 112)).build());
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> LARGE_WHITE_CHERRY_TREE = register("large_white_cherry_tree", Feature.TREE, () -> (createBushyFoliage(MysticBlocks.CHERRY_LOG.get(), MysticBlocks.WHITE_CHERRY_BLOSSOMS.get(), 13, 3, 112)).build());
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> PEONY_BUSH = register("peony_bush", Feature.TREE, () -> (new TreeConfiguration.TreeConfigurationBuilder(BlockStateProvider.simple(Blocks.OAK_LOG), new StraightTrunkPlacer(1, 0, 0), new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(MysticBlocks.BUDDING_PEONY_LEAVES.get().defaultBlockState(), 3).add(MysticBlocks.PEONY_LEAVES.get().defaultBlockState(), 3)), new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 72), new TwoLayersFeatureSize(0, 0, 0))).build());
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> BAMBOO = register("bamboo", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.BAMBOO, new ProbabilityFeatureConfiguration(0.7F), List.of(Blocks.GRASS_BLOCK, Blocks.PODZOL), 96));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> PINK_CHERRY_TREE_PLACED = register("pink_cherry_tree_placed", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.TREE, PINK_CHERRY_TREE.get().config(), List.of(Blocks.GRASS_BLOCK), 1));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> LARGE_PINK_CHERRY_TREE_PLACED = register("large_pink_cherry_tree_placed", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.TREE, LARGE_PINK_CHERRY_TREE.get().config(), List.of(Blocks.GRASS_BLOCK), 1));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> WHITE_CHERRY_TREE_PLACED = register("white_cherry_tree_placed", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.TREE, WHITE_CHERRY_TREE.get().config(), List.of(Blocks.GRASS_BLOCK), 1));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> LARGE_WHITE_CHERRY_TREE_PLACED = register("large_white_cherry_tree_placed", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.TREE, LARGE_WHITE_CHERRY_TREE.get().config(), List.of(Blocks.GRASS_BLOCK), 1));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> PEONY_BUSH_PLACED = register("peony_bush_placed", Feature.RANDOM_PATCH, () -> FeatureUtils.simplePatchConfiguration(Feature.TREE, PEONY_BUSH.get().config(), List.of(Blocks.GRASS_BLOCK), 1));
- public static final RegistryObject<ConfiguredFeature<TreeConfiguration, ?>> STRAWBERRY_TREE = register("strawberry_tree", Feature.TREE, () -> (createBushyFoliage(MysticBlocks.STRAWBERRY_LOG.get(), MysticBlocks.STRAWBERRY_BLOSSOMS.get(), 8, 0, 82)).build());
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> STRAWBERRY_BUSH = register("strawberry_bush", Feature.RANDOM_PATCH, () -> (new RandomPatchConfiguration(400, 9, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(MysticBlocks.STRAWBERRY_BUSH.get().defaultBlockState().setValue(StrawberryBushBlock.AGE, 5)))))));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> PINK_TULIP = register("pink_tulip", Feature.RANDOM_PATCH, () -> (new RandomPatchConfiguration(64, 7, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(Blocks.PINK_TULIP))))));
- public static final RegistryObject<ConfiguredFeature<RandomPatchConfiguration, ?>> WHITE_TULIP = register("white_tulip", Feature.RANDOM_PATCH, () -> (new RandomPatchConfiguration(64, 7, 2, PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(Blocks.WHITE_TULIP))))));
- private static TreeConfiguration.TreeConfigurationBuilder createBushyFoliage(Block log, Block leaves, int baseHeight, int heightRandomA, int foliageAttempts) {
- return new TreeConfiguration.TreeConfigurationBuilder(BlockStateProvider.simple(log), new FancyTrunkPlacer(baseHeight, heightRandomA, 0), BlockStateProvider.simple(leaves), new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(3), foliageAttempts), new TwoLayersFeatureSize(1, 0, 1));
- }
- public static <FC extends FeatureConfiguration, F extends Feature<FC>> RegistryObject<ConfiguredFeature<FC, ?>> register(String name, F feature, Supplier<FC> configSupplier) {
- return CONFIGURED_FEATURES.register(name, () -> new ConfiguredFeature<>(feature, configSupplier.get()));
- }
- }
- /** What's placed in the world generation. */
- public static class Placed {
- public static final RegistryObject<PlacedFeature> TREES_JACARANDA = register("trees_jacaranda", Configured.JACARANDA_TREE.getHolder().orElseThrow(), VegetationPlacements.treePlacement(RarityFilter.onAverageOnceEvery(3), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> FLOWERS_LAVENDER = register("flowers_lavender", Configured.LAVENDER.getHolder().orElseThrow(), VegetationPlacements.worldSurfaceSquaredWithCount(48));
- public static final RegistryObject<PlacedFeature> FOLIAGE_GRASS = register("foliage_grass", Configured.GRASS.getHolder().orElseThrow(), VegetationPlacements.worldSurfaceSquaredWithCount(128));
- public static final RegistryObject<PlacedFeature> FOLIAGE_LIGHT_GRASS = register("foliage_light_grass", Configured.LIGHT_GRASS.getHolder().orElseThrow(), VegetationPlacements.worldSurfaceSquaredWithCount(16));
- public static final RegistryObject<PlacedFeature> TREES_PINK_CHERRY = register("trees_pink_cherry", Configured.PINK_CHERRY_TREE_PLACED.getHolder().orElseThrow(), VegetationPlacements.treePlacement(NoiseBasedCountPlacement.of(8, 0.4D, 1), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> TREES_LARGE_PINK_CHERRY = register("trees_large_pink_cherry", Configured.LARGE_PINK_CHERRY_TREE_PLACED.getHolder().orElseThrow(), VegetationPlacements.treePlacement(NoiseBasedCountPlacement.of(6, 0.4D, 1), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> TREES_WHITE_CHERRY = register("trees_white_cherry", Configured.WHITE_CHERRY_TREE_PLACED.getHolder().orElseThrow(), VegetationPlacements.treePlacement(NoiseBasedCountPlacement.of(8, 0.4D, 1), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> TREES_LARGE_WHITE_CHERRY = register("trees_large_white_cherry", Configured.LARGE_WHITE_CHERRY_TREE_PLACED.getHolder().orElseThrow(), VegetationPlacements.treePlacement(NoiseBasedCountPlacement.of(6, 0.4D, 1), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> FOLIAGE_PEONY_BUSH = register("foliage_peony_bush", Configured.PEONY_BUSH_PLACED.getHolder().orElseThrow(), VegetationPlacements.treePlacement(NoiseBasedCountPlacement.of(80, 0.4D, 1), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> FOLIAGE_BAMBOO = register("foliage_bamboo", Configured.BAMBOO.getHolder().orElseThrow(), NoiseBasedCountPlacement.of(158, 80.0D, 0.3D), RarityFilter.onAverageOnceEvery(28), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome());
- public static final RegistryObject<PlacedFeature> TREES_STRAWBERRY = register("trees_strawberry", Configured.STRAWBERRY_TREE.getHolder().orElseThrow(), VegetationPlacements.treePlacement(RarityFilter.onAverageOnceEvery(3), Blocks.OAK_SAPLING));
- public static final RegistryObject<PlacedFeature> FOLIAGE_STRAWBERRY_BUSH = register("foliage_strawberry_bush", Configured.STRAWBERRY_BUSH.getHolder().orElseThrow(), RarityFilter.onAverageOnceEvery(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome());
- public static final RegistryObject<PlacedFeature> FLOWERS_PINK_TULIP = register("foliage_pink_tulip", Configured.PINK_TULIP.getHolder().orElseThrow(), RarityFilter.onAverageOnceEvery(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome());
- public static final RegistryObject<PlacedFeature> FLOWERS_WHITE_TULIP = register("foliage_white_tulip", Configured.WHITE_TULIP.getHolder().orElseThrow(), RarityFilter.onAverageOnceEvery(1), InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome());
- // InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP_WORLD_SURFACE, BiomeFilter.biome()
- public static RegistryObject<PlacedFeature> register(String name, Holder<? extends ConfiguredFeature<?, ?>> feature, List<PlacementModifier> modifiers) {
- return PLACED_FEATURES.register(name, () -> new PlacedFeature(Holder.hackyErase(feature), List.copyOf(modifiers)));
- }
- public static RegistryObject<PlacedFeature> register(String name, Holder<? extends ConfiguredFeature<?, ?>> feature, PlacementModifier... modifiers) {
- return register(name, feature, List.of(modifiers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement