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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…