--- a/net/minecraft/world/level/block/ScaffoldingBlock.java
+++ b/net/minecraft/world/level/block/ScaffoldingBlock.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.level.block;
 
 import com.mojang.serialization.MapCodec;
+import java.util.Iterator;
 import net.minecraft.core.BlockPos;
 import net.minecraft.core.Direction;
 import net.minecraft.server.level.ServerLevel;
@@ -17,6 +18,7 @@
 import net.minecraft.world.level.block.state.properties.BlockStateProperties;
 import net.minecraft.world.level.block.state.properties.BooleanProperty;
 import net.minecraft.world.level.block.state.properties.IntegerProperty;
+import net.minecraft.world.level.material.Fluid;
 import net.minecraft.world.level.material.FluidState;
 import net.minecraft.world.level.material.Fluids;
 import net.minecraft.world.phys.shapes.CollisionContext;
@@ -24,12 +26,13 @@
 import net.minecraft.world.phys.shapes.VoxelShape;
 
 public class ScaffoldingBlock extends Block implements SimpleWaterloggedBlock {
+
     public static final MapCodec<ScaffoldingBlock> CODEC = simpleCodec(ScaffoldingBlock::new);
     private static final int TICK_DELAY = 1;
     private static final VoxelShape STABLE_SHAPE;
     private static final VoxelShape UNSTABLE_SHAPE;
-    private static final VoxelShape UNSTABLE_SHAPE_BOTTOM = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0);
-    private static final VoxelShape BELOW_BLOCK = Shapes.block().move(0.0, -1.0, 0.0);
+    private static final VoxelShape UNSTABLE_SHAPE_BOTTOM = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
+    private static final VoxelShape BELOW_BLOCK = Shapes.block().move(0.0D, -1.0D, 0.0D);
     public static final int STABILITY_MAX_DISTANCE = 7;
     public static final IntegerProperty DISTANCE = BlockStateProperties.STABILITY_DISTANCE;
     public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
@@ -37,32 +40,22 @@
 
     @Override
     public MapCodec<ScaffoldingBlock> codec() {
-        return CODEC;
+        return ScaffoldingBlock.CODEC;
     }
 
     protected ScaffoldingBlock(BlockBehaviour.Properties settings) {
         super(settings);
-        this.registerDefaultState(
-            this.stateDefinition
-                .any()
-                .setValue(DISTANCE, Integer.valueOf(7))
-                .setValue(WATERLOGGED, Boolean.valueOf(false))
-                .setValue(BOTTOM, Boolean.valueOf(false))
-        );
+        this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(ScaffoldingBlock.DISTANCE, 7)).setValue(ScaffoldingBlock.WATERLOGGED, false)).setValue(ScaffoldingBlock.BOTTOM, false));
     }
 
     @Override
     protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
-        builder.add(DISTANCE, WATERLOGGED, BOTTOM);
+        builder.add(ScaffoldingBlock.DISTANCE, ScaffoldingBlock.WATERLOGGED, ScaffoldingBlock.BOTTOM);
     }
 
     @Override
     protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
-        if (!context.isHoldingItem(state.getBlock().asItem())) {
-            return state.getValue(BOTTOM) ? UNSTABLE_SHAPE : STABLE_SHAPE;
-        } else {
-            return Shapes.block();
-        }
+        return !context.isHoldingItem(state.getBlock().asItem()) ? ((Boolean) state.getValue(ScaffoldingBlock.BOTTOM) ? ScaffoldingBlock.UNSTABLE_SHAPE : ScaffoldingBlock.STABLE_SHAPE) : Shapes.block();
     }
 
     @Override
@@ -77,30 +70,29 @@
 
     @Override
     public BlockState getStateForPlacement(BlockPlaceContext ctx) {
-        BlockPos blockPos = ctx.getClickedPos();
-        Level level = ctx.getLevel();
-        int i = getDistance(level, blockPos);
-        return this.defaultBlockState()
-            .setValue(WATERLOGGED, Boolean.valueOf(level.getFluidState(blockPos).getType() == Fluids.WATER))
-            .setValue(DISTANCE, Integer.valueOf(i))
-            .setValue(BOTTOM, Boolean.valueOf(this.isBottom(level, blockPos, i)));
+        BlockPos blockposition = ctx.getClickedPos();
+        Level world = ctx.getLevel();
+        int i = ScaffoldingBlock.getDistance(world, blockposition);
+
+        return (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(ScaffoldingBlock.WATERLOGGED, world.getFluidState(blockposition).getType() == Fluids.WATER)).setValue(ScaffoldingBlock.DISTANCE, i)).setValue(ScaffoldingBlock.BOTTOM, this.isBottom(world, blockposition, i));
     }
 
     @Override
     protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
         if (!world.isClientSide) {
-            world.scheduleTick(pos, this, 1);
+            world.scheduleTick(pos, (Block) this, 1);
         }
+
     }
 
     @Override
     protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
-        if (state.getValue(WATERLOGGED)) {
-            world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
+        if ((Boolean) state.getValue(ScaffoldingBlock.WATERLOGGED)) {
+            world.scheduleTick(pos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(world));
         }
 
         if (!world.isClientSide()) {
-            world.scheduleTick(pos, this, 1);
+            world.scheduleTick(pos, (Block) this, 1);
         }
 
         return state;
@@ -108,56 +100,59 @@
 
     @Override
     protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
-        int i = getDistance(world, pos);
-        BlockState blockState = state.setValue(DISTANCE, Integer.valueOf(i)).setValue(BOTTOM, Boolean.valueOf(this.isBottom(world, pos, i)));
-        if (blockState.getValue(DISTANCE) == 7) {
-            if (state.getValue(DISTANCE) == 7) {
-                FallingBlockEntity.fall(world, pos, blockState);
+        int i = ScaffoldingBlock.getDistance(world, pos);
+        BlockState iblockdata1 = (BlockState) ((BlockState) state.setValue(ScaffoldingBlock.DISTANCE, i)).setValue(ScaffoldingBlock.BOTTOM, this.isBottom(world, pos, i));
+
+        if ((Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, iblockdata1.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state
+            if ((Integer) state.getValue(ScaffoldingBlock.DISTANCE) == 7) {
+                FallingBlockEntity.fall(world, pos, iblockdata1);
             } else {
                 world.destroyBlock(pos, true);
             }
-        } else if (state != blockState) {
-            world.setBlock(pos, blockState, 3);
+        } else if (state != iblockdata1) {
+            world.setBlock(pos, iblockdata1, 3);
         }
+
     }
 
     @Override
     protected boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
-        return getDistance(world, pos) < 7;
+        return ScaffoldingBlock.getDistance(world, pos) < 7;
     }
 
     @Override
     protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
-        if (context.isAbove(Shapes.block(), pos, true) && !context.isDescending()) {
-            return STABLE_SHAPE;
-        } else {
-            return state.getValue(DISTANCE) != 0 && state.getValue(BOTTOM) && context.isAbove(BELOW_BLOCK, pos, true) ? UNSTABLE_SHAPE_BOTTOM : Shapes.empty();
-        }
+        return context.isAbove(Shapes.block(), pos, true) && !context.isDescending() ? ScaffoldingBlock.STABLE_SHAPE : ((Integer) state.getValue(ScaffoldingBlock.DISTANCE) != 0 && (Boolean) state.getValue(ScaffoldingBlock.BOTTOM) && context.isAbove(ScaffoldingBlock.BELOW_BLOCK, pos, true) ? ScaffoldingBlock.UNSTABLE_SHAPE_BOTTOM : Shapes.empty());
     }
 
     @Override
     protected FluidState getFluidState(BlockState state) {
-        return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
+        return (Boolean) state.getValue(ScaffoldingBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
     }
 
     private boolean isBottom(BlockGetter world, BlockPos pos, int distance) {
-        return distance > 0 && !world.getBlockState(pos.below()).is(this);
+        return distance > 0 && !world.getBlockState(pos.below()).is((Block) this);
     }
 
     public static int getDistance(BlockGetter world, BlockPos pos) {
-        BlockPos.MutableBlockPos mutableBlockPos = pos.mutable().move(Direction.DOWN);
-        BlockState blockState = world.getBlockState(mutableBlockPos);
+        BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable().move(Direction.DOWN);
+        BlockState iblockdata = world.getBlockState(blockposition_mutableblockposition);
         int i = 7;
-        if (blockState.is(Blocks.SCAFFOLDING)) {
-            i = blockState.getValue(DISTANCE);
-        } else if (blockState.isFaceSturdy(world, mutableBlockPos, Direction.UP)) {
+
+        if (iblockdata.is(Blocks.SCAFFOLDING)) {
+            i = (Integer) iblockdata.getValue(ScaffoldingBlock.DISTANCE);
+        } else if (iblockdata.isFaceSturdy(world, blockposition_mutableblockposition, Direction.UP)) {
             return 0;
         }
 
-        for (Direction direction : Direction.Plane.HORIZONTAL) {
-            BlockState blockState2 = world.getBlockState(mutableBlockPos.setWithOffset(pos, direction));
-            if (blockState2.is(Blocks.SCAFFOLDING)) {
-                i = Math.min(i, blockState2.getValue(DISTANCE) + 1);
+        Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
+
+        while (iterator.hasNext()) {
+            Direction enumdirection = (Direction) iterator.next();
+            BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition.setWithOffset(pos, enumdirection));
+
+            if (iblockdata1.is(Blocks.SCAFFOLDING)) {
+                i = Math.min(i, (Integer) iblockdata1.getValue(ScaffoldingBlock.DISTANCE) + 1);
                 if (i == 1) {
                     break;
                 }
@@ -168,16 +163,18 @@
     }
 
     static {
-        VoxelShape voxelShape = Block.box(0.0, 14.0, 0.0, 16.0, 16.0, 16.0);
-        VoxelShape voxelShape2 = Block.box(0.0, 0.0, 0.0, 2.0, 16.0, 2.0);
-        VoxelShape voxelShape3 = Block.box(14.0, 0.0, 0.0, 16.0, 16.0, 2.0);
-        VoxelShape voxelShape4 = Block.box(0.0, 0.0, 14.0, 2.0, 16.0, 16.0);
-        VoxelShape voxelShape5 = Block.box(14.0, 0.0, 14.0, 16.0, 16.0, 16.0);
-        STABLE_SHAPE = Shapes.or(voxelShape, voxelShape2, voxelShape3, voxelShape4, voxelShape5);
-        VoxelShape voxelShape6 = Block.box(0.0, 0.0, 0.0, 2.0, 2.0, 16.0);
-        VoxelShape voxelShape7 = Block.box(14.0, 0.0, 0.0, 16.0, 2.0, 16.0);
-        VoxelShape voxelShape8 = Block.box(0.0, 0.0, 14.0, 16.0, 2.0, 16.0);
-        VoxelShape voxelShape9 = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 2.0);
-        UNSTABLE_SHAPE = Shapes.or(ScaffoldingBlock.UNSTABLE_SHAPE_BOTTOM, STABLE_SHAPE, voxelShape7, voxelShape6, voxelShape9, voxelShape8);
+        VoxelShape voxelshape = Block.box(0.0D, 14.0D, 0.0D, 16.0D, 16.0D, 16.0D);
+        VoxelShape voxelshape1 = Block.box(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 2.0D);
+        VoxelShape voxelshape2 = Block.box(14.0D, 0.0D, 0.0D, 16.0D, 16.0D, 2.0D);
+        VoxelShape voxelshape3 = Block.box(0.0D, 0.0D, 14.0D, 2.0D, 16.0D, 16.0D);
+        VoxelShape voxelshape4 = Block.box(14.0D, 0.0D, 14.0D, 16.0D, 16.0D, 16.0D);
+
+        STABLE_SHAPE = Shapes.or(voxelshape, voxelshape1, voxelshape2, voxelshape3, voxelshape4);
+        VoxelShape voxelshape5 = Block.box(0.0D, 0.0D, 0.0D, 2.0D, 2.0D, 16.0D);
+        VoxelShape voxelshape6 = Block.box(14.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
+        VoxelShape voxelshape7 = Block.box(0.0D, 0.0D, 14.0D, 16.0D, 2.0D, 16.0D);
+        VoxelShape voxelshape8 = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 2.0D);
+
+        UNSTABLE_SHAPE = Shapes.or(ScaffoldingBlock.UNSTABLE_SHAPE_BOTTOM, ScaffoldingBlock.STABLE_SHAPE, voxelshape6, voxelshape5, voxelshape8, voxelshape7);
     }
 }
