Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TreeGeneration {
- public static final List<ConfiguredFeature<?, ?>> OVERWORLD_TREES = new ArrayList<>();
- public static final List<ConfiguredFeature<?, ?>> END_TREES = new ArrayList<>();
- public static final List<ConfiguredFeature<?, ?>> NETHER_TREES = new ArrayList<>();
- private static <Config extends FeatureConfiguration> ConfiguredFeature<Config, ?> register(String name,
- ConfiguredFeature<Config, ?> configuredFeature) {
- return Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(TestMod.MODID, name),
- configuredFeature);
- }
- private static void registerTrees() {
- ConfiguredFeature<?, ?> tree = Feature.TREE
- .configured(new TreeConfiguration.TreeConfigurationBuilder(
- new SimpleStateProvider(Blocks.PINK_CONCRETE.defaultBlockState()),
- new FancyTrunkPlacer(5, 4, 6), new SimpleStateProvider(Blocks.PACKED_ICE.defaultBlockState()),
- new SimpleStateProvider(Blocks.OAK_SAPLING.defaultBlockState()),
- new RandomSpreadFoliagePlacer(ConstantInt.of(5), ConstantInt.of(5), ConstantInt.of(5), 7),
- new TwoLayersFeatureSize(5, 1, 4)).ignoreVines().build())
- .decorated(Features.Decorators.HEIGHTMAP_WITH_TREE_THRESHOLD_SQUARED)
- .decorated(FeatureDecorator.COUNT_EXTRA
- .configured(new FrequencyWithExtraChanceDecoratorConfiguration(10, .1f, 1)))
- .squared().count(20);
- OVERWORLD_TREES.add(register("funky_tree", tree));
- }
- @Mod.EventBusSubscriber(modid = TestMod.MODID, bus = Bus.FORGE)
- public static class ForgeBusSubscriber {
- @SubscribeEvent
- public static void biomeLoading(BiomeLoadingEvent event) {
- final List<Supplier<ConfiguredFeature<?, ?>>> features = event.getGeneration()
- .getFeatures(Decoration.VEGETAL_DECORATION);
- switch(event.getCategory()) {
- case NETHER -> TreeGeneration.OVERWORLD_TREES.forEach(tree -> features.add(() -> tree));
- case THEEND -> TreeGeneration.END_TREES.forEach(tree -> features.add(() -> tree));
- default -> TreeGeneration.NETHER_TREES.forEach(tree -> features.add(() -> tree));
- }
- }
- }
- @Mod.EventBusSubscriber(modid = TestMod.MODID, bus = Bus.MOD)
- public static class ModBusSubscriber {
- @SubscribeEvent
- public static void commonSetup(FMLCommonSetupEvent event) {
- event.enqueueWork(TreeGeneration::registerTrees);
- }
- }
- }
Add Comment
Please, Sign In to add comment