package net.minecraft.world.level.levelgen.feature.treedecorators;

import net.minecraft.world.level.block.state.StateHolder;
import java.util.function.Function;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.LevelWriter;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import java.util.Set;
import net.minecraft.core.BlockPos;
import java.util.List;
import java.util.Random;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.serialization.Codec;

public abstract class TreeDecorator {
    public static final Codec<TreeDecorator> CODEC;
    
    protected abstract TreeDecoratorType<?> type();
    
    public abstract void place(final LevelAccessor bqc, final Random random, final List<BlockPos> list3, final List<BlockPos> list4, final Set<BlockPos> set, final BoundingBox ctd);
    
    protected void placeVine(final LevelWriter bqh, final BlockPos fu, final BooleanProperty cga, final Set<BlockPos> set, final BoundingBox ctd) {
        this.setBlock(bqh, fu, ((StateHolder<O, BlockState>)Blocks.VINE.defaultBlockState()).<Comparable, Boolean>setValue((Property<Comparable>)cga, true), set, ctd);
    }
    
    protected void setBlock(final LevelWriter bqh, final BlockPos fu, final BlockState cfj, final Set<BlockPos> set, final BoundingBox ctd) {
        bqh.setBlock(fu, cfj, 19);
        set.add(fu);
        ctd.expand(new BoundingBox(fu, fu));
    }
    
    static {
        CODEC = Registry.TREE_DECORATOR_TYPES.dispatch((Function)TreeDecorator::type, (Function)TreeDecoratorType::codec);
    }
}
