/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.MapCodec */ package net.minecraft.world.level.block; import com.mojang.serialization.MapCodec; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.ScheduledTickAccess; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FarmBlock; import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; public class DirtPathBlock extends Block { public static final MapCodec CODEC = DirtPathBlock.simpleCodec(DirtPathBlock::new); private static final VoxelShape SHAPE = Block.column(16.0, 0.0, 15.0); public MapCodec codec() { return CODEC; } protected DirtPathBlock(BlockBehaviour.Properties properties) { super(properties); } @Override protected boolean useShapeForLightOcclusion(BlockState state) { return true; } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { if (!this.defaultBlockState().canSurvive(context.getLevel(), context.getClickedPos())) { return Block.pushEntitiesUp(this.defaultBlockState(), Blocks.DIRT.defaultBlockState(), context.getLevel(), context.getClickedPos()); } return super.getStateForPlacement(context); } @Override protected BlockState updateShape(BlockState state, LevelReader level, ScheduledTickAccess ticks, BlockPos pos, Direction directionToNeighbour, BlockPos neighbourPos, BlockState neighbourState, RandomSource random) { if (directionToNeighbour == Direction.UP && !state.canSurvive(level, pos)) { ticks.scheduleTick(pos, this, 1); } return super.updateShape(state, level, ticks, pos, directionToNeighbour, neighbourPos, neighbourState, random); } @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { FarmBlock.turnToDirt(null, state, level, pos); } @Override protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { BlockState aboveState = level.getBlockState(pos.above()); return !aboveState.isSolid() || aboveState.getBlock() instanceof FenceGateBlock; } @Override protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { return SHAPE; } @Override protected boolean isPathfindable(BlockState state, PathComputationType type) { return false; } }