--- a/net/minecraft/world/level/block/FenceGateBlock.java
+++ b/net/minecraft/world/level/block/FenceGateBlock.java
@@ -5,9 +5,11 @@
 import java.util.function.BiConsumer;
 import net.minecraft.core.BlockPos;
 import net.minecraft.core.Direction;
+import net.minecraft.core.Holder;
 import net.minecraft.sounds.SoundSource;
 import net.minecraft.tags.BlockTags;
 import net.minecraft.world.InteractionResult;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.item.context.BlockPlaceContext;
@@ -29,99 +31,82 @@
 import net.minecraft.world.phys.shapes.VoxelShape;
 
 public class FenceGateBlock extends HorizontalDirectionalBlock {
-    public static final MapCodec<FenceGateBlock> CODEC = RecordCodecBuilder.mapCodec(
-        instance -> instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter(block -> block.type), propertiesCodec()).apply(instance, FenceGateBlock::new)
-    );
+
+    public static final MapCodec<FenceGateBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+        return instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter((blockfencegate) -> {
+            return blockfencegate.type;
+        }), propertiesCodec()).apply(instance, FenceGateBlock::new);
+    });
     public static final BooleanProperty OPEN = BlockStateProperties.OPEN;
     public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
     public static final BooleanProperty IN_WALL = BlockStateProperties.IN_WALL;
-    protected static final VoxelShape Z_SHAPE = Block.box(0.0, 0.0, 6.0, 16.0, 16.0, 10.0);
-    protected static final VoxelShape X_SHAPE = Block.box(6.0, 0.0, 0.0, 10.0, 16.0, 16.0);
-    protected static final VoxelShape Z_SHAPE_LOW = Block.box(0.0, 0.0, 6.0, 16.0, 13.0, 10.0);
-    protected static final VoxelShape X_SHAPE_LOW = Block.box(6.0, 0.0, 0.0, 10.0, 13.0, 16.0);
-    protected static final VoxelShape Z_COLLISION_SHAPE = Block.box(0.0, 0.0, 6.0, 16.0, 24.0, 10.0);
-    protected static final VoxelShape X_COLLISION_SHAPE = Block.box(6.0, 0.0, 0.0, 10.0, 24.0, 16.0);
-    protected static final VoxelShape Z_SUPPORT_SHAPE = Block.box(0.0, 5.0, 6.0, 16.0, 24.0, 10.0);
-    protected static final VoxelShape X_SUPPORT_SHAPE = Block.box(6.0, 5.0, 0.0, 10.0, 24.0, 16.0);
-    protected static final VoxelShape Z_OCCLUSION_SHAPE = Shapes.or(Block.box(0.0, 5.0, 7.0, 2.0, 16.0, 9.0), Block.box(14.0, 5.0, 7.0, 16.0, 16.0, 9.0));
-    protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0, 5.0, 0.0, 9.0, 16.0, 2.0), Block.box(7.0, 5.0, 14.0, 9.0, 16.0, 16.0));
-    protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0, 2.0, 7.0, 2.0, 13.0, 9.0), Block.box(14.0, 2.0, 7.0, 16.0, 13.0, 9.0));
-    protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0, 2.0, 0.0, 9.0, 13.0, 2.0), Block.box(7.0, 2.0, 14.0, 9.0, 13.0, 16.0));
+    protected static final VoxelShape Z_SHAPE = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 16.0D, 10.0D);
+    protected static final VoxelShape X_SHAPE = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 16.0D, 16.0D);
+    protected static final VoxelShape Z_SHAPE_LOW = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 13.0D, 10.0D);
+    protected static final VoxelShape X_SHAPE_LOW = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 13.0D, 16.0D);
+    protected static final VoxelShape Z_COLLISION_SHAPE = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 24.0D, 10.0D);
+    protected static final VoxelShape X_COLLISION_SHAPE = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 24.0D, 16.0D);
+    protected static final VoxelShape Z_SUPPORT_SHAPE = Block.box(0.0D, 5.0D, 6.0D, 16.0D, 24.0D, 10.0D);
+    protected static final VoxelShape X_SUPPORT_SHAPE = Block.box(6.0D, 5.0D, 0.0D, 10.0D, 24.0D, 16.0D);
+    protected static final VoxelShape Z_OCCLUSION_SHAPE = Shapes.or(Block.box(0.0D, 5.0D, 7.0D, 2.0D, 16.0D, 9.0D), Block.box(14.0D, 5.0D, 7.0D, 16.0D, 16.0D, 9.0D));
+    protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0D, 5.0D, 0.0D, 9.0D, 16.0D, 2.0D), Block.box(7.0D, 5.0D, 14.0D, 9.0D, 16.0D, 16.0D));
+    protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0D, 2.0D, 7.0D, 2.0D, 13.0D, 9.0D), Block.box(14.0D, 2.0D, 7.0D, 16.0D, 13.0D, 9.0D));
+    protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0D, 2.0D, 0.0D, 9.0D, 13.0D, 2.0D), Block.box(7.0D, 2.0D, 14.0D, 9.0D, 13.0D, 16.0D));
     private final WoodType type;
 
     @Override
     public MapCodec<FenceGateBlock> codec() {
-        return CODEC;
+        return FenceGateBlock.CODEC;
     }
 
     public FenceGateBlock(WoodType type, BlockBehaviour.Properties settings) {
         super(settings.sound(type.soundType()));
         this.type = type;
-        this.registerDefaultState(
-            this.stateDefinition
-                .any()
-                .setValue(OPEN, Boolean.valueOf(false))
-                .setValue(POWERED, Boolean.valueOf(false))
-                .setValue(IN_WALL, Boolean.valueOf(false))
-        );
+        this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(FenceGateBlock.OPEN, false)).setValue(FenceGateBlock.POWERED, false)).setValue(FenceGateBlock.IN_WALL, false));
     }
 
     @Override
     protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
-        if (state.getValue(IN_WALL)) {
-            return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_SHAPE_LOW : Z_SHAPE_LOW;
-        } else {
-            return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_SHAPE : Z_SHAPE;
-        }
+        return (Boolean) state.getValue(FenceGateBlock.IN_WALL) ? (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_SHAPE_LOW : FenceGateBlock.Z_SHAPE_LOW) : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_SHAPE : FenceGateBlock.Z_SHAPE);
     }
 
     @Override
     protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
-        Direction.Axis axis = direction.getAxis();
-        if (state.getValue(FACING).getClockWise().getAxis() != axis) {
+        Direction.Axis enumdirection_enumaxis = direction.getAxis();
+
+        if (((Direction) state.getValue(FenceGateBlock.FACING)).getClockWise().getAxis() != enumdirection_enumaxis) {
             return super.updateShape(state, direction, neighborState, world, pos, neighborPos);
         } else {
-            boolean bl = this.isWall(neighborState) || this.isWall(world.getBlockState(pos.relative(direction.getOpposite())));
-            return state.setValue(IN_WALL, Boolean.valueOf(bl));
+            boolean flag = this.isWall(neighborState) || this.isWall(world.getBlockState(pos.relative(direction.getOpposite())));
+
+            return (BlockState) state.setValue(FenceGateBlock.IN_WALL, flag);
         }
     }
 
     @Override
     protected VoxelShape getBlockSupportShape(BlockState state, BlockGetter world, BlockPos pos) {
-        if (state.getValue(OPEN)) {
-            return Shapes.empty();
-        } else {
-            return state.getValue(FACING).getAxis() == Direction.Axis.Z ? Z_SUPPORT_SHAPE : X_SUPPORT_SHAPE;
-        }
+        return (Boolean) state.getValue(FenceGateBlock.OPEN) ? Shapes.empty() : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.Z ? FenceGateBlock.Z_SUPPORT_SHAPE : FenceGateBlock.X_SUPPORT_SHAPE);
     }
 
     @Override
     protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
-        if (state.getValue(OPEN)) {
-            return Shapes.empty();
-        } else {
-            return state.getValue(FACING).getAxis() == Direction.Axis.Z ? Z_COLLISION_SHAPE : X_COLLISION_SHAPE;
-        }
+        return (Boolean) state.getValue(FenceGateBlock.OPEN) ? Shapes.empty() : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.Z ? FenceGateBlock.Z_COLLISION_SHAPE : FenceGateBlock.X_COLLISION_SHAPE);
     }
 
     @Override
     protected VoxelShape getOcclusionShape(BlockState state, BlockGetter world, BlockPos pos) {
-        if (state.getValue(IN_WALL)) {
-            return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_OCCLUSION_SHAPE_LOW : Z_OCCLUSION_SHAPE_LOW;
-        } else {
-            return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_OCCLUSION_SHAPE : Z_OCCLUSION_SHAPE;
-        }
+        return (Boolean) state.getValue(FenceGateBlock.IN_WALL) ? (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_OCCLUSION_SHAPE_LOW : FenceGateBlock.Z_OCCLUSION_SHAPE_LOW) : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_OCCLUSION_SHAPE : FenceGateBlock.Z_OCCLUSION_SHAPE);
     }
 
     @Override
     protected boolean isPathfindable(BlockState state, PathComputationType type) {
         switch (type) {
             case LAND:
-                return state.getValue(OPEN);
+                return (Boolean) state.getValue(FenceGateBlock.OPEN);
             case WATER:
                 return false;
             case AIR:
-                return state.getValue(OPEN);
+                return (Boolean) state.getValue(FenceGateBlock.OPEN);
             default:
                 return false;
         }
@@ -129,18 +114,14 @@
 
     @Override
     public BlockState getStateForPlacement(BlockPlaceContext ctx) {
-        Level level = ctx.getLevel();
-        BlockPos blockPos = ctx.getClickedPos();
-        boolean bl = level.hasNeighborSignal(blockPos);
-        Direction direction = ctx.getHorizontalDirection();
-        Direction.Axis axis = direction.getAxis();
-        boolean bl2 = axis == Direction.Axis.Z && (this.isWall(level.getBlockState(blockPos.west())) || this.isWall(level.getBlockState(blockPos.east())))
-            || axis == Direction.Axis.X && (this.isWall(level.getBlockState(blockPos.north())) || this.isWall(level.getBlockState(blockPos.south())));
-        return this.defaultBlockState()
-            .setValue(FACING, direction)
-            .setValue(OPEN, Boolean.valueOf(bl))
-            .setValue(POWERED, Boolean.valueOf(bl))
-            .setValue(IN_WALL, Boolean.valueOf(bl2));
+        Level world = ctx.getLevel();
+        BlockPos blockposition = ctx.getClickedPos();
+        boolean flag = world.hasNeighborSignal(blockposition);
+        Direction enumdirection = ctx.getHorizontalDirection();
+        Direction.Axis enumdirection_enumaxis = enumdirection.getAxis();
+        boolean flag1 = enumdirection_enumaxis == Direction.Axis.Z && (this.isWall(world.getBlockState(blockposition.west())) || this.isWall(world.getBlockState(blockposition.east()))) || enumdirection_enumaxis == Direction.Axis.X && (this.isWall(world.getBlockState(blockposition.north())) || this.isWall(world.getBlockState(blockposition.south())));
+
+        return (BlockState) ((BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(FenceGateBlock.FACING, enumdirection)).setValue(FenceGateBlock.OPEN, flag)).setValue(FenceGateBlock.POWERED, flag)).setValue(FenceGateBlock.IN_WALL, flag1);
     }
 
     private boolean isWall(BlockState state) {
@@ -149,36 +130,35 @@
 
     @Override
     protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
-        if (state.getValue(OPEN)) {
-            state = state.setValue(OPEN, Boolean.valueOf(false));
+        if ((Boolean) state.getValue(FenceGateBlock.OPEN)) {
+            state = (BlockState) state.setValue(FenceGateBlock.OPEN, false);
             world.setBlock(pos, state, 10);
         } else {
-            Direction direction = player.getDirection();
-            if (state.getValue(FACING) == direction.getOpposite()) {
-                state = state.setValue(FACING, direction);
+            Direction enumdirection = player.getDirection();
+
+            if (state.getValue(FenceGateBlock.FACING) == enumdirection.getOpposite()) {
+                state = (BlockState) state.setValue(FenceGateBlock.FACING, enumdirection);
             }
 
-            state = state.setValue(OPEN, Boolean.valueOf(true));
+            state = (BlockState) state.setValue(FenceGateBlock.OPEN, true);
             world.setBlock(pos, state, 10);
         }
 
-        boolean bl = state.getValue(OPEN);
-        world.playSound(
-            player, pos, bl ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F
-        );
-        world.gameEvent(player, bl ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos);
+        boolean flag = (Boolean) state.getValue(FenceGateBlock.OPEN);
+
+        world.playSound(player, pos, flag ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F);
+        world.gameEvent((Entity) player, (Holder) (flag ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE), pos);
         return InteractionResult.sidedSuccess(world.isClientSide);
     }
 
     @Override
     protected void onExplosionHit(BlockState state, Level world, BlockPos pos, Explosion explosion, BiConsumer<ItemStack, BlockPos> stackMerger) {
-        if (explosion.getBlockInteraction() == Explosion.BlockInteraction.TRIGGER_BLOCK && !world.isClientSide() && !state.getValue(POWERED)) {
-            boolean bl = state.getValue(OPEN);
-            world.setBlockAndUpdate(pos, state.setValue(OPEN, Boolean.valueOf(!bl)));
-            world.playSound(
-                null, pos, bl ? this.type.fenceGateClose() : this.type.fenceGateOpen(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F
-            );
-            world.gameEvent(bl ? GameEvent.BLOCK_CLOSE : GameEvent.BLOCK_OPEN, pos, GameEvent.Context.of(state));
+        if (explosion.getBlockInteraction() == Explosion.BlockInteraction.TRIGGER_BLOCK && !world.isClientSide() && !(Boolean) state.getValue(FenceGateBlock.POWERED)) {
+            boolean flag = (Boolean) state.getValue(FenceGateBlock.OPEN);
+
+            world.setBlockAndUpdate(pos, (BlockState) state.setValue(FenceGateBlock.OPEN, !flag));
+            world.playSound((Player) null, pos, flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F);
+            world.gameEvent((Holder) (flag ? GameEvent.BLOCK_CLOSE : GameEvent.BLOCK_OPEN), pos, GameEvent.Context.of(state));
         }
 
         super.onExplosionHit(state, world, pos, explosion, stackMerger);
@@ -187,30 +167,36 @@
     @Override
     protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
         if (!world.isClientSide) {
-            boolean bl = world.hasNeighborSignal(pos);
-            if (state.getValue(POWERED) != bl) {
-                world.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(bl)).setValue(OPEN, Boolean.valueOf(bl)), 2);
-                if (state.getValue(OPEN) != bl) {
-                    world.playSound(
-                        null,
-                        pos,
-                        bl ? this.type.fenceGateOpen() : this.type.fenceGateClose(),
-                        SoundSource.BLOCKS,
-                        1.0F,
-                        world.getRandom().nextFloat() * 0.1F + 0.9F
-                    );
-                    world.gameEvent(null, bl ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos);
+            boolean flag1 = world.hasNeighborSignal(pos);
+            // CraftBukkit start
+            boolean oldPowered = state.getValue(FenceGateBlock.POWERED);
+            if (oldPowered != flag1) {
+                int newPower = flag1 ? 15 : 0;
+                int oldPower = oldPowered ? 15 : 0;
+                org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
+                org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bukkitBlock, oldPower, newPower);
+                world.getCraftServer().getPluginManager().callEvent(eventRedstone);
+                flag1 = eventRedstone.getNewCurrent() > 0;
+            }
+            // CraftBukkit end
+
+            if ((Boolean) state.getValue(FenceGateBlock.POWERED) != flag1) {
+                world.setBlock(pos, (BlockState) ((BlockState) state.setValue(FenceGateBlock.POWERED, flag1)).setValue(FenceGateBlock.OPEN, flag1), 2);
+                if ((Boolean) state.getValue(FenceGateBlock.OPEN) != flag1) {
+                    world.playSound((Player) null, pos, flag1 ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F);
+                    world.gameEvent((Entity) null, (Holder) (flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE), pos);
                 }
             }
+
         }
     }
 
     @Override
     protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
-        builder.add(FACING, OPEN, POWERED, IN_WALL);
+        builder.add(FenceGateBlock.FACING, FenceGateBlock.OPEN, FenceGateBlock.POWERED, FenceGateBlock.IN_WALL);
     }
 
     public static boolean connectsToDirection(BlockState state, Direction side) {
-        return state.getValue(FACING).getAxis() == side.getClockWise().getAxis();
+        return ((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == side.getClockWise().getAxis();
     }
 }
