Search in sources :

Example 1 with SimpleStateProvider

use of net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider in project Tropicraft by Tropicraft.

the class TropicraftTrees method createFruit.

private static AbstractTreeGrower createFruit(Supplier<? extends Block> fruitLeaves, Supplier<Supplier<? extends Block>> fruitSapling) {
    return create((server, random, beehive) -> {
        WeightedStateProvider leaves = new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(TropicraftBlocks.FRUIT_LEAVES.get().defaultBlockState(), 1).add(fruitLeaves.get().defaultBlockState(), 1));
        TreeConfiguration config = new TreeConfiguration.TreeConfigurationBuilder(new SimpleStateProvider(Blocks.OAK_LOG.defaultBlockState()), new CitrusTrunkPlacer(6, 3, 0), leaves, new SimpleStateProvider(fruitSapling.get().get().defaultBlockState()), new CitrusFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0)), new TwoLayersFeatureSize(1, 0, 2)).build();
        return Feature.TREE.configured(config);
    });
}
Also used : SimpleStateProvider(net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider) CitrusTrunkPlacer(net.tropicraft.core.common.dimension.feature.tree.CitrusTrunkPlacer) WeightedStateProvider(net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider) TwoLayersFeatureSize(net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize) CitrusFoliagePlacer(net.tropicraft.core.common.dimension.feature.tree.CitrusFoliagePlacer) TreeConfiguration(net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration)

Example 2 with SimpleStateProvider

use of net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider in project Tropicraft by Tropicraft.

the class TropicraftBiomes method onBiomeLoad.

@SubscribeEvent
public static void onBiomeLoad(BiomeLoadingEvent event) {
    ResourceLocation name = event.getName();
    if (name != null && name.getNamespace().equals(Constants.MODID)) {
        return;
    }
    Biome.BiomeCategory category = event.getCategory();
    Biome.Precipitation precipitation = event.getClimate().precipitation;
    if (precipitation == Biome.Precipitation.SNOW) {
        return;
    }
    BiomeGenerationSettingsBuilder generation = event.getGeneration();
    if (category == Biome.BiomeCategory.BEACH) {
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.NORMAL_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.CURVED_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, TropicraftFeatures.LARGE_PALM_TREE.get().configured(NoneFeatureConfiguration.INSTANCE).decorated(Features.Decorators.HEIGHTMAP_SQUARE).decorated(FeatureDecorator.COUNT_EXTRA.configured(new FrequencyWithExtraChanceDecoratorConfiguration(0, 0.08F, 1))));
    } else if (category == Biome.BiomeCategory.JUNGLE) {
        SimpleStateProvider state = new SimpleStateProvider(TropicraftBlocks.PINEAPPLE.get().defaultBlockState());
        generation.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(new RandomPatchConfiguration.GrassConfigurationBuilder(state, new DoublePlantPlacer()).tries(6).canReplace().build()).decorated(Features.Decorators.HEIGHTMAP_DOUBLE_SQUARE));
    }
}
Also used : SimpleStateProvider(net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider) Biome(net.minecraft.world.level.biome.Biome) FrequencyWithExtraChanceDecoratorConfiguration(net.minecraft.world.level.levelgen.placement.FrequencyWithExtraChanceDecoratorConfiguration) ResourceLocation(net.minecraft.resources.ResourceLocation) DoublePlantPlacer(net.minecraft.world.level.levelgen.feature.blockplacers.DoublePlantPlacer) BiomeGenerationSettingsBuilder(net.minecraftforge.common.world.BiomeGenerationSettingsBuilder) RandomPatchConfiguration(net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

SimpleStateProvider (net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider)2 ResourceLocation (net.minecraft.resources.ResourceLocation)1 Biome (net.minecraft.world.level.biome.Biome)1 DoublePlantPlacer (net.minecraft.world.level.levelgen.feature.blockplacers.DoublePlantPlacer)1 RandomPatchConfiguration (net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration)1 TreeConfiguration (net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration)1 TwoLayersFeatureSize (net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize)1 WeightedStateProvider (net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider)1 FrequencyWithExtraChanceDecoratorConfiguration (net.minecraft.world.level.levelgen.placement.FrequencyWithExtraChanceDecoratorConfiguration)1 BiomeGenerationSettingsBuilder (net.minecraftforge.common.world.BiomeGenerationSettingsBuilder)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 CitrusFoliagePlacer (net.tropicraft.core.common.dimension.feature.tree.CitrusFoliagePlacer)1 CitrusTrunkPlacer (net.tropicraft.core.common.dimension.feature.tree.CitrusTrunkPlacer)1