--- a/net/minecraft/world/level/block/DiodeBlock.java
+++ b/net/minecraft/world/level/block/DiodeBlock.java
@@ -20,9 +20,11 @@
 import net.minecraft.world.phys.shapes.CollisionContext;
 import net.minecraft.world.phys.shapes.VoxelShape;
 import net.minecraft.world.ticks.TickPriority;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
 
 public abstract class DiodeBlock extends HorizontalDirectionalBlock {
-    protected static final VoxelShape SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0);
+
+    protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
     public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
 
     protected DiodeBlock(BlockBehaviour.Properties settings) {
@@ -34,13 +36,14 @@
 
     @Override
     protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
-        return SHAPE;
+        return DiodeBlock.SHAPE;
     }
 
     @Override
     protected boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
-        BlockPos blockPos = pos.below();
-        return this.canSurviveOn(world, blockPos, world.getBlockState(blockPos));
+        BlockPos blockposition1 = pos.below();
+
+        return this.canSurviveOn(world, blockposition1, world.getBlockState(blockposition1));
     }
 
     protected boolean canSurviveOn(LevelReader world, BlockPos pos, BlockState state) {
@@ -50,16 +53,28 @@
     @Override
     protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
         if (!this.isLocked(world, pos, state)) {
-            boolean bl = state.getValue(POWERED);
-            boolean bl2 = this.shouldTurnOn(world, pos, state);
-            if (bl && !bl2) {
-                world.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(false)), 2);
-            } else if (!bl) {
-                world.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 2);
-                if (!bl2) {
-                    world.scheduleTick(pos, this, this.getDelay(state), TickPriority.VERY_HIGH);
+            boolean flag = (Boolean) state.getValue(DiodeBlock.POWERED);
+            boolean flag1 = this.shouldTurnOn(world, pos, state);
+
+            if (flag && !flag1) {
+                // CraftBukkit start
+                if (CraftEventFactory.callRedstoneChange(world, pos, 15, 0).getNewCurrent() != 0) {
+                    return;
+                }
+                // CraftBukkit end
+                world.setBlock(pos, (BlockState) state.setValue(DiodeBlock.POWERED, false), 2);
+            } else if (!flag) {
+                // CraftBukkit start
+                if (CraftEventFactory.callRedstoneChange(world, pos, 0, 15).getNewCurrent() != 15) {
+                    return;
+                }
+                // CraftBukkit end
+                world.setBlock(pos, (BlockState) state.setValue(DiodeBlock.POWERED, true), 2);
+                if (!flag1) {
+                    world.scheduleTick(pos, (Block) this, this.getDelay(state), TickPriority.VERY_HIGH);
                 }
             }
+
         }
     }
 
@@ -70,11 +85,7 @@
 
     @Override
     protected int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) {
-        if (!state.getValue(POWERED)) {
-            return 0;
-        } else {
-            return state.getValue(FACING) == direction ? this.getOutputSignal(world, pos, state) : 0;
-        }
+        return !(Boolean) state.getValue(DiodeBlock.POWERED) ? 0 : (state.getValue(DiodeBlock.FACING) == direction ? this.getOutputSignal(world, pos, state) : 0);
     }
 
     @Override
@@ -82,30 +93,39 @@
         if (state.canSurvive(world, pos)) {
             this.checkTickOnNeighbor(world, pos, state);
         } else {
-            BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
-            dropResources(state, world, pos, blockEntity);
+            BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
+
+            dropResources(state, world, pos, tileentity);
             world.removeBlock(pos, false);
+            Direction[] aenumdirection = Direction.values();
+            int i = aenumdirection.length;
 
-            for (Direction direction : Direction.values()) {
-                world.updateNeighborsAt(pos.relative(direction), this);
+            for (int j = 0; j < i; ++j) {
+                Direction enumdirection = aenumdirection[j];
+
+                world.updateNeighborsAt(pos.relative(enumdirection), this);
             }
+
         }
     }
 
     protected void checkTickOnNeighbor(Level world, BlockPos pos, BlockState state) {
         if (!this.isLocked(world, pos, state)) {
-            boolean bl = state.getValue(POWERED);
-            boolean bl2 = this.shouldTurnOn(world, pos, state);
-            if (bl != bl2 && !world.getBlockTicks().willTickThisTick(pos, this)) {
-                TickPriority tickPriority = TickPriority.HIGH;
+            boolean flag = (Boolean) state.getValue(DiodeBlock.POWERED);
+            boolean flag1 = this.shouldTurnOn(world, pos, state);
+
+            if (flag != flag1 && !world.getBlockTicks().willTickThisTick(pos, this)) {
+                TickPriority ticklistpriority = TickPriority.HIGH;
+
                 if (this.shouldPrioritize(world, pos, state)) {
-                    tickPriority = TickPriority.EXTREMELY_HIGH;
-                } else if (bl) {
-                    tickPriority = TickPriority.VERY_HIGH;
+                    ticklistpriority = TickPriority.EXTREMELY_HIGH;
+                } else if (flag) {
+                    ticklistpriority = TickPriority.VERY_HIGH;
                 }
 
-                world.scheduleTick(pos, this, this.getDelay(state), tickPriority);
+                world.scheduleTick(pos, (Block) this, this.getDelay(state), ticklistpriority);
             }
+
         }
     }
 
@@ -118,25 +138,26 @@
     }
 
     protected int getInputSignal(Level world, BlockPos pos, BlockState state) {
-        Direction direction = state.getValue(FACING);
-        BlockPos blockPos = pos.relative(direction);
-        int i = world.getSignal(blockPos, direction);
+        Direction enumdirection = (Direction) state.getValue(DiodeBlock.FACING);
+        BlockPos blockposition1 = pos.relative(enumdirection);
+        int i = world.getSignal(blockposition1, enumdirection);
+
         if (i >= 15) {
             return i;
         } else {
-            BlockState blockState = world.getBlockState(blockPos);
-            return Math.max(i, blockState.is(Blocks.REDSTONE_WIRE) ? blockState.getValue(RedStoneWireBlock.POWER) : 0);
+            BlockState iblockdata1 = world.getBlockState(blockposition1);
+
+            return Math.max(i, iblockdata1.is(Blocks.REDSTONE_WIRE) ? (Integer) iblockdata1.getValue(RedStoneWireBlock.POWER) : 0);
         }
     }
 
     protected int getAlternateSignal(SignalGetter world, BlockPos pos, BlockState state) {
-        Direction direction = state.getValue(FACING);
-        Direction direction2 = direction.getClockWise();
-        Direction direction3 = direction.getCounterClockWise();
-        boolean bl = this.sideInputDiodesOnly();
-        return Math.max(
-            world.getControlInputSignal(pos.relative(direction2), direction2, bl), world.getControlInputSignal(pos.relative(direction3), direction3, bl)
-        );
+        Direction enumdirection = (Direction) state.getValue(DiodeBlock.FACING);
+        Direction enumdirection1 = enumdirection.getClockWise();
+        Direction enumdirection2 = enumdirection.getCounterClockWise();
+        boolean flag = this.sideInputDiodesOnly();
+
+        return Math.max(world.getControlInputSignal(pos.relative(enumdirection1), enumdirection1, flag), world.getControlInputSignal(pos.relative(enumdirection2), enumdirection2, flag));
     }
 
     @Override
@@ -146,14 +167,15 @@
 
     @Override
     public BlockState getStateForPlacement(BlockPlaceContext ctx) {
-        return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
+        return (BlockState) this.defaultBlockState().setValue(DiodeBlock.FACING, ctx.getHorizontalDirection().getOpposite());
     }
 
     @Override
     public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
         if (this.shouldTurnOn(world, pos, state)) {
-            world.scheduleTick(pos, this, 1);
+            world.scheduleTick(pos, (Block) this, 1);
         }
+
     }
 
     @Override
@@ -170,10 +192,11 @@
     }
 
     protected void updateNeighborsInFront(Level world, BlockPos pos, BlockState state) {
-        Direction direction = state.getValue(FACING);
-        BlockPos blockPos = pos.relative(direction.getOpposite());
-        world.neighborChanged(blockPos, this, pos);
-        world.updateNeighborsAtExceptFromFacing(blockPos, this, direction);
+        Direction enumdirection = (Direction) state.getValue(DiodeBlock.FACING);
+        BlockPos blockposition1 = pos.relative(enumdirection.getOpposite());
+
+        world.neighborChanged(blockposition1, this, pos);
+        world.updateNeighborsAtExceptFromFacing(blockposition1, this, enumdirection);
     }
 
     protected boolean sideInputDiodesOnly() {
@@ -189,9 +212,10 @@
     }
 
     public boolean shouldPrioritize(BlockGetter world, BlockPos pos, BlockState state) {
-        Direction direction = state.getValue(FACING).getOpposite();
-        BlockState blockState = world.getBlockState(pos.relative(direction));
-        return isDiode(blockState) && blockState.getValue(FACING) != direction;
+        Direction enumdirection = ((Direction) state.getValue(DiodeBlock.FACING)).getOpposite();
+        BlockState iblockdata1 = world.getBlockState(pos.relative(enumdirection));
+
+        return DiodeBlock.isDiode(iblockdata1) && iblockdata1.getValue(DiodeBlock.FACING) != enumdirection;
     }
 
     protected abstract int getDelay(BlockState state);
