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

import net.minecraft.world.level.block.state.AbstractStateHolder;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
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.BlockGetter;
import net.minecraft.world.level.block.VineBlock;
import net.minecraft.core.Vec3i;
import net.minecraft.core.BlockPos;
import java.util.Random;
import net.minecraft.world.level.levelgen.ChunkGeneratorSettings;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;
import net.minecraft.core.Direction;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

public class VinesFeature extends Feature<NoneFeatureConfiguration> {
    private static final Direction[] DIRECTIONS;
    
    public VinesFeature(final Function<Dynamic<?>, ? extends NoneFeatureConfiguration> function) {
        super(function);
    }
    
    @Override
    public boolean place(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final BlockPos fk, final NoneFeatureConfiguration cgv) {
        final BlockPos.MutableBlockPos a7 = new BlockPos.MutableBlockPos(fk);
        for (int integer8 = fk.getY(); integer8 < 256; ++integer8) {
            a7.set(fk);
            a7.move(random.nextInt(4) - random.nextInt(4), 0, random.nextInt(4) - random.nextInt(4));
            a7.setY(integer8);
            if (bjx.isEmptyBlock(a7)) {
                for (final Direction fp12 : VinesFeature.DIRECTIONS) {
                    if (fp12 != Direction.DOWN) {
                        if (VineBlock.isAcceptableNeighbour(bjx, a7, fp12)) {
                            bjx.setBlock(a7, ((AbstractStateHolder<O, BlockState>)Blocks.VINE.defaultBlockState()).<Comparable, Boolean>setValue((Property<Comparable>)VineBlock.getPropertyForFace(fp12), true), 2);
                            break;
                        }
                    }
                }
            }
        }
        return true;
    }
    
    static {
        DIRECTIONS = Direction.values();
    }
}
