--- a/net/minecraft/world/entity/monster/Vex.java
+++ b/net/minecraft/world/entity/monster/Vex.java
@@ -42,8 +42,9 @@
 import net.minecraft.world.phys.Vec3;
 
 public class Vex extends Monster implements TraceableEntity {
+
     public static final float FLAP_DEGREES_PER_TICK = 45.836624F;
-    public static final int TICKS_PER_FLAP = Mth.ceil((float) (Math.PI * 5.0 / 4.0));
+    public static final int TICKS_PER_FLAP = Mth.ceil(3.9269907F);
     protected static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(Vex.class, EntityDataSerializers.BYTE);
     private static final int FLAG_IS_CHARGING = 1;
     @Nullable
@@ -61,7 +62,7 @@
 
     @Override
     public boolean isFlapping() {
-        return this.tickCount % TICKS_PER_FLAP == 0;
+        return this.tickCount % Vex.TICKS_PER_FLAP == 0;
     }
 
     @Override
@@ -80,6 +81,7 @@
             this.limitedLifeTicks = 20;
             this.hurt(this.damageSources().starve(), 1.0F);
         }
+
     }
 
     @Override
@@ -90,19 +92,19 @@
         this.goalSelector.addGoal(8, new Vex.VexRandomMoveGoal());
         this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 3.0F, 1.0F));
         this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F));
-        this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Raider.class).setAlertOthers());
+        this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Raider.class})).setAlertOthers());
         this.targetSelector.addGoal(2, new Vex.VexCopyOwnerTargetGoal(this));
         this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, true));
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 14.0).add(Attributes.ATTACK_DAMAGE, 4.0);
+        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 14.0D).add(Attributes.ATTACK_DAMAGE, 4.0D);
     }
 
     @Override
     protected void defineSynchedData(SynchedEntityData.Builder builder) {
         super.defineSynchedData(builder);
-        builder.define(DATA_FLAGS_ID, (byte)0);
+        builder.define(Vex.DATA_FLAGS_ID, (byte) 0);
     }
 
     @Override
@@ -115,14 +117,16 @@
         if (nbt.contains("LifeTicks")) {
             this.setLimitedLife(nbt.getInt("LifeTicks"));
         }
+
     }
 
     @Override
     public void restoreFrom(Entity original) {
         super.restoreFrom(original);
-        if (original instanceof Vex vex) {
-            this.owner = vex.getOwner();
+        if (original instanceof Vex entityvex) {
+            this.owner = entityvex.getOwner();
         }
+
     }
 
     @Override
@@ -137,6 +141,7 @@
         if (this.hasLimitedLife) {
             nbt.putInt("LifeTicks", this.limitedLifeTicks);
         }
+
     }
 
     @Nullable
@@ -155,19 +160,21 @@
     }
 
     private boolean getVexFlag(int mask) {
-        int i = this.entityData.get(DATA_FLAGS_ID);
-        return (i & mask) != 0;
+        byte b0 = (Byte) this.entityData.get(Vex.DATA_FLAGS_ID);
+
+        return (b0 & mask) != 0;
     }
 
     private void setVexFlag(int mask, boolean value) {
-        int i = this.entityData.get(DATA_FLAGS_ID);
+        int j = (Byte) this.entityData.get(Vex.DATA_FLAGS_ID);
+
         if (value) {
-            i |= mask;
+            j |= mask;
         } else {
-            i &= ~mask;
+            j &= ~mask;
         }
 
-        this.entityData.set(DATA_FLAGS_ID, (byte)(i & 0xFF));
+        this.entityData.set(Vex.DATA_FLAGS_ID, (byte) (j & 255));
     }
 
     public boolean isCharging() {
@@ -210,9 +217,10 @@
     @Nullable
     @Override
     public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable SpawnGroupData entityData) {
-        RandomSource randomSource = world.getRandom();
-        this.populateDefaultEquipmentSlots(randomSource, difficulty);
-        this.populateDefaultEquipmentEnchantments(world, randomSource, difficulty);
+        RandomSource randomsource = world.getRandom();
+
+        this.populateDefaultEquipmentSlots(randomsource, difficulty);
+        this.populateDefaultEquipmentEnchantments(world, randomsource, difficulty);
         return super.finalizeSpawn(world, difficulty, spawnReason, entityData);
     }
 
@@ -222,19 +230,52 @@
         this.setDropChance(EquipmentSlot.MAINHAND, 0.0F);
     }
 
-    class VexChargeAttackGoal extends Goal {
+    private class VexMoveControl extends MoveControl {
+
+        public VexMoveControl(final Vex entityvex) {
+            super(entityvex);
+        }
+
+        @Override
+        public void tick() {
+            if (this.operation == MoveControl.Operation.MOVE_TO) {
+                Vec3 vec3d = new Vec3(this.wantedX - Vex.this.getX(), this.wantedY - Vex.this.getY(), this.wantedZ - Vex.this.getZ());
+                double d0 = vec3d.length();
+
+                if (d0 < Vex.this.getBoundingBox().getSize()) {
+                    this.operation = MoveControl.Operation.WAIT;
+                    Vex.this.setDeltaMovement(Vex.this.getDeltaMovement().scale(0.5D));
+                } else {
+                    Vex.this.setDeltaMovement(Vex.this.getDeltaMovement().add(vec3d.scale(this.speedModifier * 0.05D / d0)));
+                    if (Vex.this.getTarget() == null) {
+                        Vec3 vec3d1 = Vex.this.getDeltaMovement();
+
+                        Vex.this.setYRot(-((float) Mth.atan2(vec3d1.x, vec3d1.z)) * 57.295776F);
+                        Vex.this.yBodyRot = Vex.this.getYRot();
+                    } else {
+                        double d1 = Vex.this.getTarget().getX() - Vex.this.getX();
+                        double d2 = Vex.this.getTarget().getZ() - Vex.this.getZ();
+
+                        Vex.this.setYRot(-((float) Mth.atan2(d1, d2)) * 57.295776F);
+                        Vex.this.yBodyRot = Vex.this.getYRot();
+                    }
+                }
+
+            }
+        }
+    }
+
+    private class VexChargeAttackGoal extends Goal {
+
         public VexChargeAttackGoal() {
             this.setFlags(EnumSet.of(Goal.Flag.MOVE));
         }
 
         @Override
         public boolean canUse() {
-            LivingEntity livingEntity = Vex.this.getTarget();
-            return livingEntity != null
-                && livingEntity.isAlive()
-                && !Vex.this.getMoveControl().hasWanted()
-                && Vex.this.random.nextInt(reducedTickDelay(7)) == 0
-                && Vex.this.distanceToSqr(livingEntity) > 4.0;
+            LivingEntity entityliving = Vex.this.getTarget();
+
+            return entityliving != null && entityliving.isAlive() && !Vex.this.getMoveControl().hasWanted() && Vex.this.random.nextInt(reducedTickDelay(7)) == 0 ? Vex.this.distanceToSqr((Entity) entityliving) > 4.0D : false;
         }
 
         @Override
@@ -244,10 +285,12 @@
 
         @Override
         public void start() {
-            LivingEntity livingEntity = Vex.this.getTarget();
-            if (livingEntity != null) {
-                Vec3 vec3 = livingEntity.getEyePosition();
-                Vex.this.moveControl.setWantedPosition(vec3.x, vec3.y, vec3.z, 1.0);
+            LivingEntity entityliving = Vex.this.getTarget();
+
+            if (entityliving != null) {
+                Vec3 vec3d = entityliving.getEyePosition();
+
+                Vex.this.moveControl.setWantedPosition(vec3d.x, vec3d.y, vec3d.z, 1.0D);
             }
 
             Vex.this.setIsCharging(true);
@@ -266,105 +309,85 @@
 
         @Override
         public void tick() {
-            LivingEntity livingEntity = Vex.this.getTarget();
-            if (livingEntity != null) {
-                if (Vex.this.getBoundingBox().intersects(livingEntity.getBoundingBox())) {
-                    Vex.this.doHurtTarget(livingEntity);
+            LivingEntity entityliving = Vex.this.getTarget();
+
+            if (entityliving != null) {
+                if (Vex.this.getBoundingBox().intersects(entityliving.getBoundingBox())) {
+                    Vex.this.doHurtTarget(entityliving);
                     Vex.this.setIsCharging(false);
                 } else {
-                    double d = Vex.this.distanceToSqr(livingEntity);
-                    if (d < 9.0) {
-                        Vec3 vec3 = livingEntity.getEyePosition();
-                        Vex.this.moveControl.setWantedPosition(vec3.x, vec3.y, vec3.z, 1.0);
+                    double d0 = Vex.this.distanceToSqr((Entity) entityliving);
+
+                    if (d0 < 9.0D) {
+                        Vec3 vec3d = entityliving.getEyePosition();
+
+                        Vex.this.moveControl.setWantedPosition(vec3d.x, vec3d.y, vec3d.z, 1.0D);
                     }
                 }
+
             }
         }
     }
 
-    class VexCopyOwnerTargetGoal extends TargetGoal {
-        private final TargetingConditions copyOwnerTargeting = TargetingConditions.forNonCombat().ignoreLineOfSight().ignoreInvisibilityTesting();
+    private class VexRandomMoveGoal extends Goal {
 
-        public VexCopyOwnerTargetGoal(final PathfinderMob mob) {
-            super(mob, false);
+        public VexRandomMoveGoal() {
+            this.setFlags(EnumSet.of(Goal.Flag.MOVE));
         }
 
         @Override
         public boolean canUse() {
-            return Vex.this.owner != null && Vex.this.owner.getTarget() != null && this.canAttack(Vex.this.owner.getTarget(), this.copyOwnerTargeting);
+            return !Vex.this.getMoveControl().hasWanted() && Vex.this.random.nextInt(reducedTickDelay(7)) == 0;
         }
 
         @Override
-        public void start() {
-            Vex.this.setTarget(Vex.this.owner.getTarget());
-            super.start();
-        }
-    }
-
-    class VexMoveControl extends MoveControl {
-        public VexMoveControl(final Vex owner) {
-            super(owner);
+        public boolean canContinueToUse() {
+            return false;
         }
 
         @Override
         public void tick() {
-            if (this.operation == MoveControl.Operation.MOVE_TO) {
-                Vec3 vec3 = new Vec3(this.wantedX - Vex.this.getX(), this.wantedY - Vex.this.getY(), this.wantedZ - Vex.this.getZ());
-                double d = vec3.length();
-                if (d < Vex.this.getBoundingBox().getSize()) {
-                    this.operation = MoveControl.Operation.WAIT;
-                    Vex.this.setDeltaMovement(Vex.this.getDeltaMovement().scale(0.5));
-                } else {
-                    Vex.this.setDeltaMovement(Vex.this.getDeltaMovement().add(vec3.scale(this.speedModifier * 0.05 / d)));
+            BlockPos blockposition = Vex.this.getBoundOrigin();
+
+            if (blockposition == null) {
+                blockposition = Vex.this.blockPosition();
+            }
+
+            for (int i = 0; i < 3; ++i) {
+                BlockPos blockposition1 = blockposition.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7);
+
+                // Paper start - Don't load chunks
+                final net.minecraft.world.level.block.state.BlockState blockState = Vex.this.level().getBlockStateIfLoaded(blockposition1);
+                if (blockState != null && blockState.isAir()) {
+                    // Paper end - Don't load chunks
+                    Vex.this.moveControl.setWantedPosition((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 0.25D);
                     if (Vex.this.getTarget() == null) {
-                        Vec3 vec32 = Vex.this.getDeltaMovement();
-                        Vex.this.setYRot(-((float)Mth.atan2(vec32.x, vec32.z)) * (180.0F / (float)Math.PI));
-                        Vex.this.yBodyRot = Vex.this.getYRot();
-                    } else {
-                        double e = Vex.this.getTarget().getX() - Vex.this.getX();
-                        double f = Vex.this.getTarget().getZ() - Vex.this.getZ();
-                        Vex.this.setYRot(-((float)Mth.atan2(e, f)) * (180.0F / (float)Math.PI));
-                        Vex.this.yBodyRot = Vex.this.getYRot();
+                        Vex.this.getLookControl().setLookAt((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D, 180.0F, 20.0F);
                     }
+                    break;
                 }
             }
+
         }
     }
 
-    class VexRandomMoveGoal extends Goal {
-        public VexRandomMoveGoal() {
-            this.setFlags(EnumSet.of(Goal.Flag.MOVE));
-        }
+    private class VexCopyOwnerTargetGoal extends TargetGoal {
 
-        @Override
-        public boolean canUse() {
-            return !Vex.this.getMoveControl().hasWanted() && Vex.this.random.nextInt(reducedTickDelay(7)) == 0;
+        private final TargetingConditions copyOwnerTargeting = TargetingConditions.forNonCombat().ignoreLineOfSight().ignoreInvisibilityTesting();
+
+        public VexCopyOwnerTargetGoal(final PathfinderMob entitycreature) {
+            super(entitycreature, false);
         }
 
         @Override
-        public boolean canContinueToUse() {
-            return false;
+        public boolean canUse() {
+            return Vex.this.owner != null && Vex.this.owner.getTarget() != null && this.canAttack(Vex.this.owner.getTarget(), this.copyOwnerTargeting);
         }
 
         @Override
-        public void tick() {
-            BlockPos blockPos = Vex.this.getBoundOrigin();
-            if (blockPos == null) {
-                blockPos = Vex.this.blockPosition();
-            }
-
-            for (int i = 0; i < 3; i++) {
-                BlockPos blockPos2 = blockPos.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7);
-                if (Vex.this.level().isEmptyBlock(blockPos2)) {
-                    Vex.this.moveControl
-                        .setWantedPosition((double)blockPos2.getX() + 0.5, (double)blockPos2.getY() + 0.5, (double)blockPos2.getZ() + 0.5, 0.25);
-                    if (Vex.this.getTarget() == null) {
-                        Vex.this.getLookControl()
-                            .setLookAt((double)blockPos2.getX() + 0.5, (double)blockPos2.getY() + 0.5, (double)blockPos2.getZ() + 0.5, 180.0F, 20.0F);
-                    }
-                    break;
-                }
-            }
+        public void start() {
+            Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit
+            super.start();
         }
     }
 }
