45 lines
1.8 KiB
Java
45 lines
1.8 KiB
Java
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 byg, final BlockGetter bjd, final BlockPos fk) {
|
|
final Block bpe5 = byg.getBlock();
|
|
return bpe5 == Blocks.GRASS_BLOCK || bpe5 == Blocks.DIRT || bpe5 == Blocks.COARSE_DIRT || bpe5 == Blocks.PODZOL || bpe5 == Blocks.FARMLAND;
|
|
}
|
|
|
|
@Override
|
|
public BlockState updateShape(final BlockState byg1, final Direction fp, final BlockState byg3, final LevelAccessor bju, final BlockPos fk5, final BlockPos fk6) {
|
|
if (!byg1.canSurvive(bju, fk5)) {
|
|
return Blocks.AIR.defaultBlockState();
|
|
}
|
|
return super.updateShape(byg1, fp, byg3, bju, fk5, fk6);
|
|
}
|
|
|
|
@Override
|
|
public boolean canSurvive(final BlockState byg, final LevelReader bjw, final BlockPos fk) {
|
|
final BlockPos fk2 = fk.below();
|
|
return this.mayPlaceOn(bjw.getBlockState(fk2), bjw, fk2);
|
|
}
|
|
|
|
@Override
|
|
public boolean propagatesSkylightDown(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isPathfindable(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final PathComputationType cqo) {
|
|
return (cqo == PathComputationType.AIR && !this.hasCollision) || super.isPathfindable(byg, bjd, fk, cqo);
|
|
}
|
|
}
|