package net.minecraft.world.level.block;

import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class BushBlock extends Block {
    protected BushBlock(final Properties c) {
        super(c);
    }
    
    protected boolean mayPlaceOn(final BlockState cfj, final BlockGetter bpg, final BlockPos fu) {
        return cfj.is(Blocks.GRASS_BLOCK) || cfj.is(Blocks.DIRT) || cfj.is(Blocks.COARSE_DIRT) || cfj.is(Blocks.PODZOL) || cfj.is(Blocks.FARMLAND);
    }
    
    @Override
    public BlockState updateShape(final BlockState cfj1, final Direction fz, final BlockState cfj3, final LevelAccessor bqc, final BlockPos fu5, final BlockPos fu6) {
        if (!cfj1.canSurvive(bqc, fu5)) {
            return Blocks.AIR.defaultBlockState();
        }
        return super.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        final BlockPos fu2 = fu.below();
        return this.mayPlaceOn(bqd.getBlockState(fu2), bqd, fu2);
    }
    
    @Override
    public boolean propagatesSkylightDown(final BlockState cfj, final BlockGetter bpg, final BlockPos fu) {
        return cfj.getFluidState().isEmpty();
    }
    
    @Override
    public boolean isPathfindable(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final PathComputationType czg) {
        return (czg == PathComputationType.AIR && !this.hasCollision) || super.isPathfindable(cfj, bpg, fu, czg);
    }
}
