Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.google.common.collect.ImmutableList;
- import com.meepshadow.mysticsbiomes.init.ModBlocks;
- import net.minecraft.block.BlockState;
- import net.minecraft.block.Blocks;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.util.registry.Registry;
- import net.minecraft.util.registry.WorldGenRegistries;
- import net.minecraft.world.biome.BiomeGenerationSettings;
- import net.minecraft.world.gen.GenerationStage;
- import net.minecraft.world.gen.Heightmap;
- import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
- import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
- import net.minecraft.world.gen.feature.*;
- import net.minecraft.world.gen.foliageplacer.BlobFoliagePlacer;
- import net.minecraft.world.gen.foliageplacer.BushFoliagePlacer;
- import net.minecraft.world.gen.foliageplacer.FancyFoliagePlacer;
- import net.minecraft.world.gen.placement.*;
- import net.minecraft.world.gen.trunkplacer.FancyTrunkPlacer;
- import net.minecraft.world.gen.trunkplacer.StraightTrunkPlacer;
- import java.util.OptionalInt;
- import java.util.function.Supplier;
- public class ModFeatures {
- 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();
- private static final ConfiguredFeature<?, ?> OAK_SHRUB = register("oak_shrub", Feature.TREE.withConfiguration(OAK_SHRUB_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(10));
- 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))));
- //Tree Config Features
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- 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()));
- //Tree Configs
- 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))));
- 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))));
- 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))));
- 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))));
- 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))));
- //Plant Config Features
- private static final BlockClusterFeatureConfig LAVENDER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.LAVENDER.get()), new SimpleBlockPlacer())).tries(16).build();
- private static final BlockClusterFeatureConfig STRAWBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.STRAWBERRY_BUSH.get()), new SimpleBlockPlacer())).tries(16).build();
- private static final BlockClusterFeatureConfig PINK_WILDFLOWER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.PINK_WILDFLOWER.get()), new SimpleBlockPlacer())).tries(8).build();
- private static final BlockClusterFeatureConfig WHITE_WILDFLOWER_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.WHITE_WILDFLOWER.get()), new SimpleBlockPlacer())).tries(8).build();
- private static final BlockClusterFeatureConfig GRASS_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(States.GRASS.get()), new SimpleBlockPlacer())).tries(32).build();
- //Plant Configs
- private static final ConfiguredFeature<?, ?> LAVENDER_FLOWERS = register("lavender_flowers", Feature.RANDOM_PATCH.withConfiguration(LAVENDER_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(90));
- 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));
- 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));
- 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));
- private static final ConfiguredFeature<?, ?> GRASS = register("grass", Feature.RANDOM_PATCH.withConfiguration(GRASS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(50));
- //BlockStates
- static final class States {
- //Tree Stuff
- public static final Supplier<BlockState> LAVENDER_LOG = () -> ModBlocks.LAVENDER_LOG.get().getDefaultState();
- public static final Supplier<BlockState> STRAWBERRY_LOG = () -> ModBlocks.STRAWBERRY_LOG.get().getDefaultState();
- public static final Supplier<BlockState> CHERRY_LOG = () -> ModBlocks.CHERRY_LOG.get().getDefaultState();
- public static final Supplier<BlockState> LAVENDER_BLOSSOM_LEAVES = () -> ModBlocks.LAVENDER_BLOSSOM_LEAVES.get().getDefaultState();
- public static final Supplier<BlockState> SWEET_BLOSSOM_LEAVES = () -> ModBlocks.SWEET_BLOSSOM_LEAVES.get().getDefaultState();
- public static final Supplier<BlockState> STRAWBERRY_BLOSSOM_LEAVES = () -> ModBlocks.STRAWBERRY_BLOSSOM_LEAVES.get().getDefaultState();
- public static final Supplier<BlockState> PINK_CHERRY_BLOSSOM_LEAVES = () -> ModBlocks.PINK_CHERRY_BLOSSOM_LEAVES.get().getDefaultState();
- public static final Supplier<BlockState> WHITE_CHERRY_BLOSSOM_LEAVES = () -> ModBlocks.WHITE_CHERRY_BLOSSOM_LEAVES.get().getDefaultState();
- //Plant Stuff
- protected static final Supplier<BlockState> GRASS = Blocks.GRASS::getDefaultState;
- protected static final Supplier<BlockState> LAVENDER = () -> ModBlocks.LAVENDER.get().getDefaultState();
- protected static final Supplier<BlockState> STRAWBERRY_BUSH = () -> ModBlocks.STRAWBERRY_BUSH.get().getDefaultState();
- protected static final Supplier<BlockState> WHITE_WILDFLOWER = () -> ModBlocks.WHITE_WILDFLOWER.get().getDefaultState();
- protected static final Supplier<BlockState> PINK_WILDFLOWER = () -> ModBlocks.PINK_WILDFLOWER.get().getDefaultState();
- }
- //Biome Features
- public static void withStrawberryFieldsFeatures(BiomeGenerationSettings.Builder builder) {
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, STRAWBERRY_BUSHES);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_WILDFLOWER);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PINK_WILDFLOWER);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, STRAWBERRY_BLOSSOM_TREE);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, SWEET_BLOSSOM_TREE);
- }
- public static void withLavenderMeadowFeatures(BiomeGenerationSettings.Builder builder) {
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, LAVENDER_FLOWERS);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, LAVENDER_BLOSSOM_TREE);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
- }
- public static void withCherryBlossomForestBiome(BiomeGenerationSettings.Builder builder) {
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PINK_CHERRY_BLOSSOM_TREE);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_CHERRY_BLOSSOM_TREE);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, OAK_SHRUB);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, WHITE_WILDFLOWER);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, GRASS);
- builder.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BAMBOO);
- }
- //Misc
- private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
- return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, key, configuredFeature);
- }
- public static int getSkyColorWithTemperatureModifier(float temperature) {
- float lvt_1_1_ = temperature / 3.0F;
- lvt_1_1_ = MathHelper.clamp(lvt_1_1_, -1.0F, 1.0F);
- return MathHelper.hsvToRGB(0.62222224F - lvt_1_1_ * 0.05F, 0.5F + lvt_1_1_ * 0.1F, 1.0F);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement