Advertisement
jayhillx

MysticFeatures

Dec 3rd, 2022
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.80 KB | None | 0 0
  1. package com.mysticsbiomes.core.init;
  2.  
  3. import com.mysticsbiomes.core.MysticsBiomes;
  4. import net.minecraft.core.Holder;
  5. import net.minecraft.data.BuiltinRegistries;
  6. import net.minecraft.data.worldgen.placement.VegetationPlacements;
  7. import net.minecraft.util.random.SimpleWeightedRandomList;
  8. import net.minecraft.util.valueproviders.ConstantInt;
  9. import net.minecraft.util.valueproviders.UniformInt;
  10. import net.minecraft.world.level.block.Blocks;
  11. import net.minecraft.world.level.block.state.BlockState;
  12. import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
  13. import net.minecraft.world.level.levelgen.feature.Feature;
  14. import net.minecraft.world.level.levelgen.feature.configurations.*;
  15. import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize;
  16. import net.minecraft.world.level.levelgen.feature.foliageplacers.RandomSpreadFoliagePlacer;
  17. import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
  18. import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
  19. import net.minecraft.world.level.levelgen.feature.trunkplacers.BendingTrunkPlacer;
  20. import net.minecraft.world.level.levelgen.placement.*;
  21.  
  22. import java.util.List;
  23.  
  24. import static net.minecraft.data.worldgen.placement.PlacementUtils.*;
  25.  
  26. public class MysticFeatures {
  27.    
  28.     public static final Holder<ConfiguredFeature<?, ?>> 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(), 4)), new RandomSpreadFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 32), new TwoLayersFeatureSize(1, 0, 1))).build());
  29.     public static final Holder<ConfiguredFeature<?, ?>> LAVENDER = register("lavender", Feature.RANDOM_PATCH, (new RandomPatchConfiguration(182, 9, 9, onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(MysticBlocks.LAVENDER.get()))))));
  30.     public static final Holder<ConfiguredFeature<?, ?>> GRASS = register("grass", Feature.RANDOM_PATCH, (new RandomPatchConfiguration(222, 7, 7, onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(BlockStateProvider.simple(Blocks.GRASS))))));
  31.  
  32.     /** What's placed in the world generation. */
  33.     public static final Holder<PlacedFeature> TREES_JACARANDA = register("trees_jacaranda", JACARANDA_TREE, VegetationPlacements.treePlacement(RarityFilter.onAverageOnceEvery(4)));
  34.     public static final Holder<PlacedFeature> FLOWERS_LAVENDER = register("flowers_lavender", LAVENDER, VegetationPlacements.worldSurfaceSquaredWithCount(18));
  35.     public static final Holder<PlacedFeature> FOLIAGE_GRASS = register("foliage_grass", GRASS);
  36.  
  37.     private static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<ConfiguredFeature<?, ?>> register(String name, F feature, FC config) {
  38.         return BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, MysticsBiomes.modLoc(name), new ConfiguredFeature<>(feature, config));
  39.     }
  40.  
  41.     private static Holder<PlacedFeature> register(String name, Holder<? extends ConfiguredFeature<?, ?>> configuredFeature, List<PlacementModifier> modifiers) {
  42.         return BuiltinRegistries.register(BuiltinRegistries.PLACED_FEATURE, MysticsBiomes.modLoc(name), new PlacedFeature(Holder.hackyErase(configuredFeature), modifiers));
  43.     }
  44.  
  45.     private static Holder<PlacedFeature> register(String name, Holder<? extends ConfiguredFeature<?, ?>> configuredFeature, PlacementModifier... modifiers) {
  46.         return register(name, configuredFeature, List.of(modifiers));
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement