Posted May 1, 20214 yr Hello, in older Forge versions, I created a tree using my own TreeGrower: public static ConfiguredFeature<BaseTreeFeatureConfig, ?> tree_rubber = Feature.TREE.configured( new BaseTreeFeatureConfig.Builder( new SimpleBlockStateProvider(ModBlocks.rubber_log.get().defaultBlockState()), new SimpleBlockStateProvider(ModBlocks.rubber_leaves.get().defaultBlockState()), new BlobFoliagePlacer( /* radius: */ FeatureSpread.of( 2, //base 0 //spread ), /* offset: */ FeatureSpread.of( 0, //base 0 //spread ), /* height: */ 3 ), new StraightTrunkPlacer( 4, //baseHeight 2, //heightRandA 0 //heightRandB ), new TwoLayerFeature( 1, //limit 0, //lowerSize 1 //upperSize ) ).ignoreVines().build() and the sapling for this tree could be created using BLOCKS.register("rubber_sapling", () -> new SaplingBlock( new RubberTree(), AbstractBlock.Properties.of(Material.PLANT) .randomTicks() .noCollission() .instabreak() .sound(SoundType.GRASS) ) ); With 1.16.4, I can simply create this tree from a configured feature json. Let's call this file "data/[mymod]/world/configured_feature/rubber.json": { "config": { "max_water_depth": 0, "ignore_vines": true, "heightmap": "OCEAN_FLOOR", "minimum_size": { "limit": 1, "lower_size": 0, "upper_size": 1, "type": "minecraft:two_layers_feature_size" }, "decorators": [], "trunk_provider": { "state": { "Properties": { "axis": "y" }, "Name": "bigmachines:rubber_log" }, "type": "minecraft:simple_state_provider" }, "leaves_provider": { "state": { "Properties": { "persistent": "false", "distance": "7" }, "Name": "minecraft:rubber_leaves" }, "type": "minecraft:simple_state_provider" }, "foliage_placer": { "radius": 2, "offset": 0, "height": 3, "type": "minecraft:blob_foliage_placer" }, "trunk_placer": { "base_height": 4, "height_rand_a": 2, "height_rand_b": 0, "type": "minecraft:straight_trunk_placer" } }, "type": "minecraft:tree" } Which should do basically the same thing. My question is how do I register a sapling for this tree? Edited May 2, 20214 yr by scrouthtv formatted code
May 1, 20214 yr Author Appearantly, I can inject the json tree into a java field: Quote @ObjectHolder("[mymod]:rubber") public static final Feature<BaseTreeFeatureConfig> rubber_tree; https://mcforge.readthedocs.io/en/1.16.x/concepts/registries/#using-objectholder However, this is a `Feature<BaseTreeConfig>`, but I need a `ConfiguredFeature<BaseTreeConfig, ?>` instead. How do I get the other one?
May 2, 20214 yr Author Someone on discord told me to overwrite the `Tree` class: ``` public class DynamicTree extends Tree { final ResourceLocation configuredFeatureId; private ConfiguredFeature<BaseTreeFeatureConfig,?> treeFeature; public DynamicTree(ResourceLocation configuredFeatureId) { this.configuredFeatureId = configuredFeatureId; } @Nullable @Override protected ConfiguredFeature<BaseTreeFeatureConfig, ?> getTreeFeature(Random randomIn, boolean largeHive) { return treeFeature; } @Override @SuppressWarnings("unchecked") public boolean attemptGrowTree(ServerWorld world, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, Random rand) { MutableRegistry<ConfiguredFeature<?, ?>> registry = world.func_241828_r().getRegistry(Registry.CONFIGURED_FEATURE_KEY); ConfiguredFeature<?, ?> feature = registry.getOrDefault(configuredFeatureId); if(feature != null && feature.config instanceof BaseTreeFeatureConfig) { this.treeFeature = (ConfiguredFeature<BaseTreeFeatureConfig, ?>)feature; } else { this.treeFeature = null; return false; } return super.attemptGrowTree(world, chunkGenerator, pos, state, rand); } } ```
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.