package me.km.blocks;

import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.trees.Tree;
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import net.minecraft.world.gen.foliageplacer.BlobFoliagePlacer;
import net.minecraftforge.common.IPlantable;

public class ModTree extends Tree {
    private TreeFeatureConfig treeConfig = null;

    @Nullable
    @Override
    protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random r, boolean p_225546_2_) {
        return Feature.NORMAL_TREE.withConfiguration(treeConfig);
    }

    public void setConfig(BlockState wood, BlockState leaves, IPlantable sapling) {
        treeConfig = (new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(wood), new SimpleBlockStateProvider(leaves), new BlobFoliagePlacer(2, 0)))
                .baseHeight(5)
                .heightRandA(2)
                .foliageHeight(3)
                .ignoreVines()
                .setSapling(sapling)
                .build();
    }
}
