Jump to content

Tree Decorator

NCP Bails

Recommended Posts

I'm porting a 1.18.2 mod of mine to 1.19.2, and my tree decorator isn't working correctly. 

I have a custom tree that is supposed to generate with my custom decorator, but when I try to open a world I get the 'load in safe mode' screen. When I replace the AvocadoBundleTreeDecorator with CocoaDecorator it works, so the decorator is definitely the problem.

public static final Holder<ConfiguredFeature<TreeConfiguration, ?>> AVOCADO_TREE =
            FeatureUtils.register("avocado", Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder(
                    new StraightTrunkPlacer(3, 2, 0),
                    new AcaciaFoliagePlacer(ConstantInt.of(3), ConstantInt.of(0)),
                    new TwoLayersFeatureSize(1, 0, 1))
                    .decorators(ImmutableList.of(new AvocadoBundleTreeDecorator(1))).ignoreVines().build());

I'm not sure what the issue is, as AvocadoBundleTreeDecorator is set out almost identically to the 1.19.2 CocoaDecorator, and it functioned fine in the 1.18.2 version.

public class AvocadoBundleTreeDecorator extends TreeDecorator {
    public static final Codec<AvocadoBundleTreeDecorator> CODEC = Codec.floatRange(0.0F, 1.0F).fieldOf("probability").xmap(AvocadoBundleTreeDecorator::new, (p_69989_) -> {
        return p_69989_.probability;
    private final float probability;

    public AvocadoBundleTreeDecorator(float p_69976_) {
        this.probability = p_69976_;

    protected TreeDecoratorType<?> type() { return TreeDecoratorType.LEAVE_VINE; }

    public void place(TreeDecorator.Context p_226028_) {
        RandomSource randomsource = p_226028_.random();
        if (!(randomsource.nextFloat() >= this.probability)) {
            List<BlockPos> list = p_226028_.logs();
            int i = list.get(0).getY();
            list.stream().filter((p_69980_) -> {
                return p_69980_.getY() - i <= 2;
            }).forEach((p_226026_) -> {
                for(Direction direction : Direction.Plane.HORIZONTAL) {
                    if (randomsource.nextFloat() <= 0.25F) {
                        Direction direction1 = direction.getOpposite();
                        BlockPos blockpos = p_226026_.offset(direction1.getStepX(), 0, direction1.getStepZ());
                        if (p_226028_.isAir(blockpos)) {
                            p_226028_.setBlock(blockpos, ModBlocks.AVOCADO_BUNDLE.get().defaultBlockState());

Here is the Github page if needed.

Link to comment
Share on other sites

Props for showing all the code, so I can see what your problem is.

But you could have saved some time if you just posted the error instead making me build and run your project to see it.


Caused by: java.lang.ClassCastException: class com.ncpbails.culturaldelights.world.feature.tree.treedecorator.AvocadoBundleTreeDecorator cannot be cast to class net.minecraft.world.level.levelgen.feature.treedecorators.LeaveVineDecorator (com.ncpbails.culturaldelights.world.feature.tree.treedecorator.AvocadoBundleTreeDecorator is in module culturaldelights@0.0NONE of loader 'TRANSFORMER' @6f70a21b; net.minecraft.world.level.levelgen.feature.treedecorators.LeaveVineDecorator is in module minecraft@1.19.2 of loader 'TRANSFORMER' @6f70a21b)
        at com.mojang.serialization.MapEncoder$1.encode(MapEncoder.java:26) ~[datafixerupper-5.0.28.jar%23147!/:?] {}

You have;


protected TreeDecoratorType<?> type() { return TreeDecoratorType.LEAVE_VINE; }


Which uses a LeaveVineDecorator according to its CODEC.

You need to create and register your own TreeDecoratorType that uses your codec so it knows how to (de)serialize your decorator to and from json

The relevant registry is 



By the way, modifying the builtin registries to create Configured/PlacedFeatures hasn't been the correct way to do it since 1.18.1 (if it was even correct then)

and won't work at all with Mojang's new way of doing things in 1.19.3


If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.