Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
55 views
in Technique[技术] by (71.8m points)

java - Attempting to Create Custom Biome with Custom Tree as a Feature

I am able to generate my custom tree in different biomes. However, I am trying to create a custom biome to prevent the trees from spawning too often in the world.

This is a custom Feature class. If there are simpler ways to do this, please let me know. I am rather new to this, so I am open to learning more efficient tricks.

package com.collinhoskins.mccourse.world.feature;

import com.collinhoskins.mccourse.MCCourseMod;
import com.collinhoskins.mccourse.block.ModBlocks;
import com.collinhoskins.mccourse.block.RedwoodTree;
import com.collinhoskins.mccourse.world.gen.ModTreeGeneration;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.World;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.blockstateprovider.BlockStateProvider;
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.DarkOakFoliagePlacer;
import net.minecraft.world.gen.foliageplacer.MegaPineFoliagePlacer;
import net.minecraft.world.gen.trunkplacer.DarkOakTrunkPlacer;
import net.minecraft.world.gen.trunkplacer.GiantTrunkPlacer;
import net.minecraft.world.gen.trunkplacer.StraightTrunkPlacer;
import net.minecraftforge.fml.config.ModConfig;

import java.util.OptionalInt;

import static net.minecraft.util.registry.Registry.register;

public class ModConfiguredFeatures
{
    private static final int BASE_HEIGHT = 30;
    private static final int FIRST_RANDOM_HEIGHT = 20 ;
    private static final int SECOND_RANDOM_HEIGHT = 40;

    private static final int LEAVE_RADIUS = 4;
    private static final int LEAVE_OFFSET = 7;
    private static final int LEAVE_HEIGHT = 25;


//    public static final ConfiguredFeature<?, ?> FOREST_REDWOOD =
//            Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, "redwood_forest",
//                    Feature.TREE.withConfiguration(new SimpleBlockStateProvider(REDWOOD_LOG.get().getDefaultState()),
//                            new SimpleBlockStateProvider(ModBlocks.REDWOOD_LEAVES.get().getDefaultState()),
//                            new MegaPineFoliagePlacer(FeatureSpread.func_242252_a(LEAVE_RADIUS),
//                                    FeatureSpread.func_242252_a(LEAVE_OFFSET), FeatureSpread.func_242252_a(LEAVE_HEIGHT)),
//                            new GiantTrunkPlacer(BASE_HEIGHT, FIRST_RANDOM_HEIGHT, SECOND_RANDOM_HEIGHT),
//                            new TwoLayerFeature(1, 0, 1)
//                   ));
    public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> REDWOOD =
        register("redwood", Feature.TREE.withConfiguration(new SimpleBlockStateProvider(ModBlocks.REDWOOD_LOG.get().getDefaultState()),
                    new SimpleBlockStateProvider(ModBlocks.REDWOOD_LEAVES.get().getDefaultState()),
                    new MegaPineFoliagePlacer(FeatureSpread.func_242252_a(LEAVE_RADIUS),
                            FeatureSpread.func_242252_a(LEAVE_OFFSET), FeatureSpread.func_242252_a(LEAVE_HEIGHT)),
                    new GiantTrunkPlacer(BASE_HEIGHT, FIRST_RANDOM_HEIGHT, SECOND_RANDOM_HEIGHT),
                    new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build();
}


Thank you!

question from:https://stackoverflow.com/questions/65841134/attempting-to-create-custom-biome-with-custom-tree-as-a-feature

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...