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;

public class BushBlock extends Block {
    protected BushBlock(final Properties c) {
        super(c);
    }
    
    protected boolean mayPlaceOn(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        final Block bph5 = byj.getBlock();
        return bph5 == Blocks.GRASS_BLOCK || bph5 == Blocks.DIRT || bph5 == Blocks.COARSE_DIRT || bph5 == Blocks.PODZOL || bph5 == Blocks.FARMLAND;
    }
    
    @Override
    public BlockState updateShape(final BlockState byj1, final Direction fp, final BlockState byj3, final LevelAccessor bjx, final BlockPos fk5, final BlockPos fk6) {
        if (!byj1.canSurvive(bjx, fk5)) {
            return Blocks.AIR.defaultBlockState();
        }
        return super.updateShape(byj1, fp, byj3, bjx, fk5, fk6);
    }
    
    @Override
    public boolean canSurvive(final BlockState byj, final LevelReader bjz, final BlockPos fk) {
        final BlockPos fk2 = fk.below();
        return this.mayPlaceOn(bjz.getBlockState(fk2), bjz, fk2);
    }
    
    @Override
    public boolean propagatesSkylightDown(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        return true;
    }
    
    @Override
    public boolean isPathfindable(final BlockState byj, final BlockGetter bjg, final BlockPos fk, final PathComputationType cqr) {
        return (cqr == PathComputationType.AIR && !this.hasCollision) || super.isPathfindable(byj, bjg, fk, cqr);
    }
}
