Advertisement
jayhillx

ModFeatures-1.16.4

Jan 1st, 2021
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.56 KB | None | 0 0
  1. import com.google.common.collect.ImmutableList;
  2. import com.meepshadow.mysticsbiomes.init.ModBlocks;
  3. import net.minecraft.block.BlockState;
  4. import net.minecraft.block.Blocks;
  5. import net.minecraft.util.math.MathHelper;
  6. import net.minecraft.util.registry.Registry;
  7. import net.minecraft.util.registry.WorldGenRegistries;
  8. import net.minecraft.world.biome.BiomeGenerationSettings;
  9. import net.minecraft.world.gen.GenerationStage;
  10. import net.minecraft.world.gen.Heightmap;
  11. import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
  12. import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
  13. import net.minecraft.world.gen.feature.*;
  14. import net.minecraft.world.gen.foliageplacer.BlobFoliagePlacer;
  15. import net.minecraft.world.gen.foliageplacer.BushFoliagePlacer;
  16. import net.minecraft.world.gen.foliageplacer.FancyFoliagePlacer;
  17. import net.minecraft.world.gen.placement.*;
  18. import net.minecraft.world.gen.trunkplacer.FancyTrunkPlacer;
  19. import net.minecraft.world.gen.trunkplacer.StraightTrunkPlacer;
  20.  
  21. import java.util.OptionalInt;
  22. import java.util.function.Supplier;
  23.  
  24. public class ModFeatures {
  25.  
  26. private static final BaseTreeFeatureConfig OAK_SHRUB_CONFIG = (new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.OAK_LOG.getDefaultState()), new SimpleBlockStateProvider(Blocks.OAK_LEAVES.getDefaultState()), new BushFoliagePlacer(FeatureSpread.func_242253_a(2, 0), FeatureSpread.func_242253_a(1, 0), 2), new StraightTrunkPlacer(1, 0, 0), new TwoLayerFeature(0, 0, 0))).func_236702_a_(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES).build();
  27.  
  28. private static final ConfiguredFeature<?, ?> OAK_SHRUB = register("oak_shrub", Feature.TREE.withConfiguration(OAK_SHRUB_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(10));
  29. private static final ConfiguredFeature<?, ?> BAMBOO = register("bamboo", Feature.BAMBOO.withConfiguration(new ProbabilityConfig(0.2F)).withPlacement(Features.Placements.BAMBOO_PLACEMENT).square().withPlacement(Placement.COUNT_NOISE_BIASED.configure(new TopSolidWithNoiseConfig(32, 25.0D, 0.2D))));
  30.  
  31. //Tree Config Features
  32. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> FANCY_LAVENDER_TREE = register("fancy_lavender_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.LAVENDER_LOG.get()), new SimpleBlockStateProvider(States.LAVENDER_BLOSSOM_LEAVES.get()), new FancyFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(4), 4), new FancyTrunkPlacer(3, 11, 0), new TwoLayerFeature(0, 0, 0, OptionalInt.of(4)))).setIgnoreVines().func_236702_a_(Heightmap.Type.MOTION_BLOCKING).build()));
  33. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> LAVENDER_TREE = register("lavender_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.LAVENDER_LOG.get()), new SimpleBlockStateProvider(States.LAVENDER_BLOSSOM_LEAVES.get()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));
  34. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> FANCY_SWEET_TREE = register("fancy_sweet_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_LOG.get()), new SimpleBlockStateProvider(States.SWEET_BLOSSOM_LEAVES.get()), new FancyFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(4), 4), new FancyTrunkPlacer(3, 11, 0), new TwoLayerFeature(0, 0, 0, OptionalInt.of(4)))).setIgnoreVines().func_236702_a_(Heightmap.Type.MOTION_BLOCKING).build()));
  35. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> SWEET_TREE = register("sweet_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_LOG.get()), new SimpleBlockStateProvider(States.SWEET_BLOSSOM_LEAVES.get()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));
  36. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> FANCY_STRAWBERRY_TREE = register("fancy_strawberry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_LOG.get()), new SimpleBlockStateProvider(States.STRAWBERRY_BLOSSOM_LEAVES.get()), new FancyFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(4), 4), new FancyTrunkPlacer(3, 11, 0), new TwoLayerFeature(0, 0, 0, OptionalInt.of(4)))).setIgnoreVines().func_236702_a_(Heightmap.Type.MOTION_BLOCKING).build()));
  37. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> STRAWBERRY_TREE = register("strawberry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_LOG.get()), new SimpleBlockStateProvider(States.STRAWBERRY_BLOSSOM_LEAVES.get()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));
  38. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> FANCY_WHITE_CHERRY_TREE = register("fancy_white_cherry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.CHERRY_LOG.get()), new SimpleBlockStateProvider(States.WHITE_CHERRY_BLOSSOM_LEAVES.get()), new FancyFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(4), 4), new FancyTrunkPlacer(3, 11, 0), new TwoLayerFeature(0, 0, 0, OptionalInt.of(4)))).setIgnoreVines().func_236702_a_(Heightmap.Type.MOTION_BLOCKING).build()));
  39. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> WHITE_CHERRY_TREE = register("white_cherry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.CHERRY_LOG.get()), new SimpleBlockStateProvider(States.WHITE_CHERRY_BLOSSOM_LEAVES.get()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));
  40. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> FANCY_PINK_CHERRY_TREE = register("fancy_pink_cherry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.CHERRY_LOG.get()), new SimpleBlockStateProvider(States.PINK_CHERRY_BLOSSOM_LEAVES.get()), new FancyFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(4), 4), new FancyTrunkPlacer(3, 11, 0), new TwoLayerFeature(0, 0, 0, OptionalInt.of(4)))).setIgnoreVines().func_236702_a_(Heightmap.Type.MOTION_BLOCKING).build()));
  41. public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> PINK_CHERRY_TREE = register("pink_cherry_tree", Feature.TREE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(States.CHERRY_LOG.get()), new SimpleBlockStateProvider(States.PINK_CHERRY_BLOSSOM_LEAVES.get()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));
  42.  
  43. //Tree Configs
  44. private static final ConfiguredFeature<?, ?> LAVENDER_BLOSSOM_TREE = register("lavender_blossom_tree", Feature.RANDOM_SELECTOR.withConfiguration(new MultipleRandomFeatureConfig(ImmutableList.of(Features.OAK.withChance(0.5F), FANCY_LAVENDER_TREE.withChance(0.3F)), LAVENDER_TREE)).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(2, 0.5F, 1))));
  45. private static final ConfiguredFeature<?, ?> SWEET_BLOSSOM_TREE = register("sweet_blossom_tree", Feature.RANDOM_SELECTOR.withConfiguration(new MultipleRandomFeatureConfig(ImmutableList.of(Features.OAK.withChance(0.3F), FANCY_SWEET_TREE.withChance(0.3F)), SWEET_TREE)).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(2, 0.5F, 1))));
  46. private static final ConfiguredFeature<?, ?> STRAWBERRY_BLOSSOM_TREE = register("strawberry_blossom_tree", Feature.RANDOM_SELECTOR.withConfiguration(new MultipleRandomFeatureConfig(ImmutableList.of(Features.OAK.withChance(0.3F), FANCY_STRAWBERRY_TREE.withChance(0.3F)), STRAWBERRY_TREE)).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(2, 0.5F, 1))));
  47. private static final ConfiguredFeature<?, ?> PINK_CHERRY_BLOSSOM_TREE = register("pink_cherry_blossom_tree", Feature.RANDOM_SELECTOR.withConfiguration(new MultipleRandomFeatureConfig(ImmutableList.of(Features.FANCY_OAK.withChance(0.5F), FANCY_PINK_CHERRY_TREE.withChance(0.1F)), FANCY_PINK_CHERRY_TREE)).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(2, 0.05F, 1))));
  48. private static final ConfiguredFeature<?, ?> WHITE_CHERRY_BLOSSOM_TREE = register("white_cherry_blossom_tree", Feature.RANDOM_SELECTOR.withConfiguration(new MultipleRandomFeatureConfig(ImmutableList.of(Features.FANCY_OAK.withChance(0.5F), FANCY_WHITE_CHERRY_TREE.withChance(0.1F)), FANCY_WHITE_CHERRY_TREE)).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(2, 0.05F, 1))));
  49.  
  50. //Plant Config Features
  51. private static final BlockClusterFeatureConfig LAVENDER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.LAVENDER.get()), new SimpleBlockPlacer())).tries(16).build();
  52. private static final BlockClusterFeatureConfig STRAWBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_BUSH.get()), new SimpleBlockPlacer())).tries(16).build();
  53. private static final BlockClusterFeatureConfig PINK_WILDFLOWER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.PINK_WILDFLOWER.get()), new SimpleBlockPlacer())).tries(8).build();
  54. private static final BlockClusterFeatureConfig WHITE_WILDFLOWER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.WHITE_WILDFLOWER.get()), new SimpleBlockPlacer())).tries(8).build();
  55. private static final BlockClusterFeatureConfig GRASS_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.GRASS.get()), new SimpleBlockPlacer())).tries(32).build();
  56.  
  57. //Plant Configs
  58. private static final ConfiguredFeature<?, ?> LAVENDER_FLOWERS = register("lavender_flowers", Feature.RANDOM_PATCH.withConfiguration(LAVENDER_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(90));
  59. private static final ConfiguredFeature<?, ?> STRAWBERRY_BUSHES = register("strawberry_bush", Feature.RANDOM_PATCH.withConfiguration(STRAWBERRY_BUSH_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(22));
  60. private static final ConfiguredFeature<?, ?> PINK_WILDFLOWER = register("pink_wildflower", Feature.RANDOM_PATCH.withConfiguration(PINK_WILDFLOWER_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(8));
  61. private static final ConfiguredFeature<?, ?> WHITE_WILDFLOWER = register("white_wildflower", Feature.RANDOM_PATCH.withConfiguration(WHITE_WILDFLOWER_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(8));
  62. private static final ConfiguredFeature<?, ?> GRASS = register("grass", Feature.RANDOM_PATCH.withConfiguration(GRASS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(50));
  63.  
  64. //BlockStates
  65. static final class States {
  66. //Tree Stuff
  67. public static final Supplier<BlockState> LAVENDER_LOG = () -> ModBlocks.LAVENDER_LOG.get().getDefaultState();
  68. public static final Supplier<BlockState> STRAWBERRY_LOG = () -> ModBlocks.STRAWBERRY_LOG.get().getDefaultState();
  69. public static final Supplier<BlockState> CHERRY_LOG = () -> ModBlocks.CHERRY_LOG.get().getDefaultState();
  70. public static final Supplier<BlockState> LAVENDER_BLOSSOM_LEAVES = () -> ModBlocks.LAVENDER_BLOSSOM_LEAVES.get().getDefaultState();
  71. public static final Supplier<BlockState> SWEET_BLOSSOM_LEAVES = () -> ModBlocks.SWEET_BLOSSOM_LEAVES.get().getDefaultState();
  72. public static final Supplier<BlockState> STRAWBERRY_BLOSSOM_LEAVES = () -> ModBlocks.STRAWBERRY_BLOSSOM_LEAVES.get().getDefaultState();
  73. public static final Supplier<BlockState> PINK_CHERRY_BLOSSOM_LEAVES = () -> ModBlocks.PINK_CHERRY_BLOSSOM_LEAVES.get().getDefaultState();
  74. public static final Supplier<BlockState> WHITE_CHERRY_BLOSSOM_LEAVES = () -> ModBlocks.WHITE_CHERRY_BLOSSOM_LEAVES.get().getDefaultState();
  75. //Plant Stuff
  76. protected static final Supplier<BlockState> GRASS = Blocks.GRASS::getDefaultState;
  77. protected static final Supplier<BlockState> LAVENDER = () -> ModBlocks.LAVENDER.get().getDefaultState();
  78. protected static final Supplier<BlockState> STRAWBERRY_BUSH = () -> ModBlocks.STRAWBERRY_BUSH.get().getDefaultState();
  79. protected static final Supplier<BlockState> WHITE_WILDFLOWER = () -> ModBlocks.WHITE_WILDFLOWER.get().getDefaultState();
  80. protected static final Supplier<BlockState> PINK_WILDFLOWER = () -> ModBlocks.PINK_WILDFLOWER.get().getDefaultState();
  81. }
  82.  
  83. //Biome Features
  84. public static void withStrawberryFieldsFeatures(BiomeGenerationSettings.Builder builder) {
  85. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, STRAWBERRY_BUSHES);
  86. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_WILDFLOWER);
  87. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PINK_WILDFLOWER);
  88. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
  89. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, STRAWBERRY_BLOSSOM_TREE);
  90. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, SWEET_BLOSSOM_TREE);
  91. }
  92. public static void withLavenderMeadowFeatures(BiomeGenerationSettings.Builder builder) {
  93. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, LAVENDER_FLOWERS);
  94. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, LAVENDER_BLOSSOM_TREE);
  95. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
  96. }
  97. public static void withCherryBlossomForestBiome(BiomeGenerationSettings.Builder builder) {
  98. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PINK_CHERRY_BLOSSOM_TREE);
  99. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_CHERRY_BLOSSOM_TREE);
  100. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, OAK_SHRUB);
  101. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_WILDFLOWER);
  102. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
  103. builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BAMBOO);
  104. }
  105.  
  106.  
  107. //Misc
  108. private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
  109. return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, key, configuredFeature);
  110. }
  111. public static int getSkyColorWithTemperatureModifier(float temperature) {
  112. float lvt_1_1_ = temperature / 3.0F;
  113. lvt_1_1_ = MathHelper.clamp(lvt_1_1_, -1.0F, 1.0F);
  114. return MathHelper.hsvToRGB(0.62222224F - lvt_1_1_ * 0.05F, 0.5F + lvt_1_1_ * 0.1F, 1.0F);
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement