--- a/net/minecraft/world/entity/monster/Guardian.java
+++ b/net/minecraft/world/entity/monster/Guardian.java
@@ -48,6 +48,7 @@
 import org.joml.Vector3f;
 
 public class Guardian extends Monster {
+
     protected static final int ATTACK_TIME = 80;
     private static final EntityDataAccessor<Boolean> DATA_ID_MOVING = SynchedEntityData.defineId(Guardian.class, EntityDataSerializers.BOOLEAN);
     private static final EntityDataAccessor<Integer> DATA_ID_ATTACK_TARGET = SynchedEntityData.defineId(Guardian.class, EntityDataSerializers.INT);
@@ -62,6 +63,7 @@
     private boolean clientSideTouchedGround;
     @Nullable
     public RandomStrollGoal randomStrollGoal;
+    public Guardian.GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field
 
     public Guardian(EntityType<? extends Guardian> type, Level world) {
         super(type, world);
@@ -74,16 +76,17 @@
 
     @Override
     protected void registerGoals() {
-        MoveTowardsRestrictionGoal moveTowardsRestrictionGoal = new MoveTowardsRestrictionGoal(this, 1.0D);
+        MoveTowardsRestrictionGoal pathfindergoalmovetowardsrestriction = new MoveTowardsRestrictionGoal(this, 1.0D);
+
         this.randomStrollGoal = new RandomStrollGoal(this, 1.0D, 80);
-        this.goalSelector.addGoal(4, new Guardian.GuardianAttackGoal(this));
-        this.goalSelector.addGoal(5, moveTowardsRestrictionGoal);
+        this.goalSelector.addGoal(4, this.guardianAttackGoal = new Guardian.GuardianAttackGoal(this)); // CraftBukkit - assign field
+        this.goalSelector.addGoal(5, pathfindergoalmovetowardsrestriction);
         this.goalSelector.addGoal(7, this.randomStrollGoal);
         this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
         this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Guardian.class, 12.0F, 0.01F));
         this.goalSelector.addGoal(9, new RandomLookAroundGoal(this));
         this.randomStrollGoal.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
-        moveTowardsRestrictionGoal.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
+        pathfindergoalmovetowardsrestriction.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
         this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, LivingEntity.class, 10, true, false, new Guardian.GuardianAttackSelector(this)));
     }
 
@@ -99,8 +102,8 @@
     @Override
     protected void defineSynchedData() {
         super.defineSynchedData();
-        this.entityData.define(DATA_ID_MOVING, false);
-        this.entityData.define(DATA_ID_ATTACK_TARGET, 0);
+        this.entityData.define(Guardian.DATA_ID_MOVING, false);
+        this.entityData.define(Guardian.DATA_ID_ATTACK_TARGET, 0);
     }
 
     @Override
@@ -114,11 +117,11 @@
     }
 
     public boolean isMoving() {
-        return this.entityData.get(DATA_ID_MOVING);
+        return (Boolean) this.entityData.get(Guardian.DATA_ID_MOVING);
     }
 
     void setMoving(boolean retracted) {
-        this.entityData.set(DATA_ID_MOVING, retracted);
+        this.entityData.set(Guardian.DATA_ID_MOVING, retracted);
     }
 
     public int getAttackDuration() {
@@ -126,11 +129,11 @@
     }
 
     public void setActiveAttackTarget(int entityId) {
-        this.entityData.set(DATA_ID_ATTACK_TARGET, entityId);
+        this.entityData.set(Guardian.DATA_ID_ATTACK_TARGET, entityId);
     }
 
     public boolean hasActiveAttackTarget() {
-        return this.entityData.get(DATA_ID_ATTACK_TARGET) != 0;
+        return (Integer) this.entityData.get(Guardian.DATA_ID_ATTACK_TARGET) != 0;
     }
 
     @Nullable
@@ -141,9 +144,10 @@
             if (this.clientSideCachedAttackTarget != null) {
                 return this.clientSideCachedAttackTarget;
             } else {
-                Entity entity = this.level().getEntity(this.entityData.get(DATA_ID_ATTACK_TARGET));
+                Entity entity = this.level().getEntity((Integer) this.entityData.get(Guardian.DATA_ID_ATTACK_TARGET));
+
                 if (entity instanceof LivingEntity) {
-                    this.clientSideCachedAttackTarget = (LivingEntity)entity;
+                    this.clientSideCachedAttackTarget = (LivingEntity) entity;
                     return this.clientSideCachedAttackTarget;
                 } else {
                     return null;
@@ -157,7 +161,7 @@
     @Override
     public void onSyncedDataUpdated(EntityDataAccessor<?> data) {
         super.onSyncedDataUpdated(data);
-        if (DATA_ID_ATTACK_TARGET.equals(data)) {
+        if (Guardian.DATA_ID_ATTACK_TARGET.equals(data)) {
             this.clientSideAttackTime = 0;
             this.clientSideCachedAttackTarget = null;
         }
@@ -204,14 +208,16 @@
         if (this.isAlive()) {
             if (this.level().isClientSide) {
                 this.clientSideTailAnimationO = this.clientSideTailAnimation;
+                Vec3 vec3d;
+
                 if (!this.isInWater()) {
                     this.clientSideTailAnimationSpeed = 2.0F;
-                    Vec3 vec3 = this.getDeltaMovement();
-                    if (vec3.y > 0.0D && this.clientSideTouchedGround && !this.isSilent()) {
+                    vec3d = this.getDeltaMovement();
+                    if (vec3d.y > 0.0D && this.clientSideTouchedGround && !this.isSilent()) {
                         this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), this.getFlopSound(), this.getSoundSource(), 1.0F, 1.0F, false);
                     }
 
-                    this.clientSideTouchedGround = vec3.y < 0.0D && this.level().loadedAndEntityCanStandOn(this.blockPosition().below(), this);
+                    this.clientSideTouchedGround = vec3d.y < 0.0D && this.level().loadedAndEntityCanStandOn(this.blockPosition().below(), this);
                 } else if (this.isMoving()) {
                     if (this.clientSideTailAnimationSpeed < 0.5F) {
                         this.clientSideTailAnimationSpeed = 4.0F;
@@ -233,10 +239,10 @@
                 }
 
                 if (this.isMoving() && this.isInWater()) {
-                    Vec3 vec32 = this.getViewVector(0.0F);
+                    vec3d = this.getViewVector(0.0F);
 
-                    for(int i = 0; i < 2; ++i) {
-                        this.level().addParticle(ParticleTypes.BUBBLE, this.getRandomX(0.5D) - vec32.x * 1.5D, this.getRandomY() - vec32.y * 1.5D, this.getRandomZ(0.5D) - vec32.z * 1.5D, 0.0D, 0.0D, 0.0D);
+                    for (int i = 0; i < 2; ++i) {
+                        this.level().addParticle(ParticleTypes.BUBBLE, this.getRandomX(0.5D) - vec3d.x * 1.5D, this.getRandomY() - vec3d.y * 1.5D, this.getRandomZ(0.5D) - vec3d.z * 1.5D, 0.0D, 0.0D, 0.0D);
                     }
                 }
 
@@ -245,23 +251,25 @@
                         ++this.clientSideAttackTime;
                     }
 
-                    LivingEntity livingEntity = this.getActiveAttackTarget();
-                    if (livingEntity != null) {
-                        this.getLookControl().setLookAt(livingEntity, 90.0F, 90.0F);
+                    LivingEntity entityliving = this.getActiveAttackTarget();
+
+                    if (entityliving != null) {
+                        this.getLookControl().setLookAt(entityliving, 90.0F, 90.0F);
                         this.getLookControl().tick();
-                        double d = (double)this.getAttackAnimationScale(0.0F);
-                        double e = livingEntity.getX() - this.getX();
-                        double f = livingEntity.getY(0.5D) - this.getEyeY();
-                        double g = livingEntity.getZ() - this.getZ();
-                        double h = Math.sqrt(e * e + f * f + g * g);
-                        e /= h;
-                        f /= h;
-                        g /= h;
-                        double j = this.random.nextDouble();
+                        double d0 = (double) this.getAttackAnimationScale(0.0F);
+                        double d1 = entityliving.getX() - this.getX();
+                        double d2 = entityliving.getY(0.5D) - this.getEyeY();
+                        double d3 = entityliving.getZ() - this.getZ();
+                        double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
 
-                        while(j < h) {
-                            j += 1.8D - d + this.random.nextDouble() * (1.7D - d);
-                            this.level().addParticle(ParticleTypes.BUBBLE, this.getX() + e * j, this.getEyeY() + f * j, this.getZ() + g * j, 0.0D, 0.0D, 0.0D);
+                        d1 /= d4;
+                        d2 /= d4;
+                        d3 /= d4;
+                        double d5 = this.random.nextDouble();
+
+                        while (d5 < d4) {
+                            d5 += 1.8D - d0 + this.random.nextDouble() * (1.7D - d0);
+                            this.level().addParticle(ParticleTypes.BUBBLE, this.getX() + d1 * d5, this.getEyeY() + d2 * d5, this.getZ() + d3 * d5, 0.0D, 0.0D, 0.0D);
                         }
                     }
                 }
@@ -270,7 +278,7 @@
             if (this.isInWaterOrBubble()) {
                 this.setAirSupply(300);
             } else if (this.onGround()) {
-                this.setDeltaMovement(this.getDeltaMovement().add((double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F), 0.5D, (double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F)));
+                this.setDeltaMovement(this.getDeltaMovement().add((double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F), 0.5D, (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F)));
                 this.setYRot(this.random.nextFloat() * 360.0F);
                 this.setOnGround(false);
                 this.hasImpulse = true;
@@ -297,11 +305,11 @@
     }
 
     public float getAttackAnimationScale(float tickDelta) {
-        return ((float)this.clientSideAttackTime + tickDelta) / (float)this.getAttackDuration();
+        return ((float) this.clientSideAttackTime + tickDelta) / (float) this.getAttackDuration();
     }
 
     public float getClientSideAttackTime() {
-        return (float)this.clientSideAttackTime;
+        return (float) this.clientSideAttackTime;
     }
 
     @Override
@@ -319,10 +327,12 @@
             return false;
         } else {
             if (!this.isMoving() && !source.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !source.is(DamageTypes.THORNS)) {
-                Entity var4 = source.getDirectEntity();
-                if (var4 instanceof LivingEntity) {
-                    LivingEntity livingEntity = (LivingEntity)var4;
-                    livingEntity.hurt(this.damageSources().thorns(this), 2.0F);
+                Entity entity = source.getDirectEntity();
+
+                if (entity instanceof LivingEntity) {
+                    LivingEntity entityliving = (LivingEntity) entity;
+
+                    entityliving.hurt(this.damageSources().thorns(this), 2.0F);
                 }
             }
 
@@ -359,7 +369,62 @@
         return new Vector3f(0.0F, dimensions.height + 0.125F * scaleFactor, 0.0F);
     }
 
+    private static class GuardianMoveControl extends MoveControl {
+
+        private final Guardian guardian;
+
+        public GuardianMoveControl(Guardian guardian) {
+            super(guardian);
+            this.guardian = guardian;
+        }
+
+        @Override
+        public void tick() {
+            if (this.operation == MoveControl.Operation.MOVE_TO && !this.guardian.getNavigation().isDone()) {
+                Vec3 vec3d = new Vec3(this.wantedX - this.guardian.getX(), this.wantedY - this.guardian.getY(), this.wantedZ - this.guardian.getZ());
+                double d0 = vec3d.length();
+                double d1 = vec3d.x / d0;
+                double d2 = vec3d.y / d0;
+                double d3 = vec3d.z / d0;
+                float f = (float) (Mth.atan2(vec3d.z, vec3d.x) * 57.2957763671875D) - 90.0F;
+
+                this.guardian.setYRot(this.rotlerp(this.guardian.getYRot(), f, 90.0F));
+                this.guardian.yBodyRot = this.guardian.getYRot();
+                float f1 = (float) (this.speedModifier * this.guardian.getAttributeValue(Attributes.MOVEMENT_SPEED));
+                float f2 = Mth.lerp(0.125F, this.guardian.getSpeed(), f1);
+
+                this.guardian.setSpeed(f2);
+                double d4 = Math.sin((double) (this.guardian.tickCount + this.guardian.getId()) * 0.5D) * 0.05D;
+                double d5 = Math.cos((double) (this.guardian.getYRot() * 0.017453292F));
+                double d6 = Math.sin((double) (this.guardian.getYRot() * 0.017453292F));
+                double d7 = Math.sin((double) (this.guardian.tickCount + this.guardian.getId()) * 0.75D) * 0.05D;
+
+                this.guardian.setDeltaMovement(this.guardian.getDeltaMovement().add(d4 * d5, d7 * (d6 + d5) * 0.25D + (double) f2 * d2 * 0.1D, d4 * d6));
+                LookControl controllerlook = this.guardian.getLookControl();
+                double d8 = this.guardian.getX() + d1 * 2.0D;
+                double d9 = this.guardian.getEyeY() + d2 / d0;
+                double d10 = this.guardian.getZ() + d3 * 2.0D;
+                double d11 = controllerlook.getWantedX();
+                double d12 = controllerlook.getWantedY();
+                double d13 = controllerlook.getWantedZ();
+
+                if (!controllerlook.isLookingAtTarget()) {
+                    d11 = d8;
+                    d12 = d9;
+                    d13 = d10;
+                }
+
+                this.guardian.getLookControl().setLookAt(Mth.lerp(0.125D, d11, d8), Mth.lerp(0.125D, d12, d9), Mth.lerp(0.125D, d13, d10), 10.0F, 40.0F);
+                this.guardian.setMoving(true);
+            } else {
+                this.guardian.setSpeed(0.0F);
+                this.guardian.setMoving(false);
+            }
+        }
+    }
+
     public static class GuardianAttackGoal extends Goal {
+
         private final Guardian guardian;
         public int attackTime;
         private final boolean elder;
@@ -372,22 +437,24 @@
 
         @Override
         public boolean canUse() {
-            LivingEntity livingEntity = this.guardian.getTarget();
-            return livingEntity != null && livingEntity.isAlive();
+            LivingEntity entityliving = this.guardian.getTarget();
+
+            return entityliving != null && entityliving.isAlive();
         }
 
         @Override
         public boolean canContinueToUse() {
-            return super.canContinueToUse() && (this.elder || this.guardian.getTarget() != null && this.guardian.distanceToSqr(this.guardian.getTarget()) > 9.0D);
+            return super.canContinueToUse() && (this.elder || this.guardian.getTarget() != null && this.guardian.distanceToSqr((Entity) this.guardian.getTarget()) > 9.0D);
         }
 
         @Override
         public void start() {
             this.attackTime = -10;
             this.guardian.getNavigation().stop();
-            LivingEntity livingEntity = this.guardian.getTarget();
-            if (livingEntity != null) {
-                this.guardian.getLookControl().setLookAt(livingEntity, 90.0F, 90.0F);
+            LivingEntity entityliving = this.guardian.getTarget();
+
+            if (entityliving != null) {
+                this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F);
             }
 
             this.guardian.hasImpulse = true;
@@ -396,7 +463,7 @@
         @Override
         public void stop() {
             this.guardian.setActiveAttackTarget(0);
-            this.guardian.setTarget((LivingEntity)null);
+            this.guardian.setTarget((LivingEntity) null);
             this.guardian.randomStrollGoal.trigger();
         }
 
@@ -407,21 +474,23 @@
 
         @Override
         public void tick() {
-            LivingEntity livingEntity = this.guardian.getTarget();
-            if (livingEntity != null) {
+            LivingEntity entityliving = this.guardian.getTarget();
+
+            if (entityliving != null) {
                 this.guardian.getNavigation().stop();
-                this.guardian.getLookControl().setLookAt(livingEntity, 90.0F, 90.0F);
-                if (!this.guardian.hasLineOfSight(livingEntity)) {
-                    this.guardian.setTarget((LivingEntity)null);
+                this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F);
+                if (!this.guardian.hasLineOfSight(entityliving)) {
+                    this.guardian.setTarget((LivingEntity) null);
                 } else {
                     ++this.attackTime;
                     if (this.attackTime == 0) {
-                        this.guardian.setActiveAttackTarget(livingEntity.getId());
+                        this.guardian.setActiveAttackTarget(entityliving.getId());
                         if (!this.guardian.isSilent()) {
-                            this.guardian.level().broadcastEntityEvent(this.guardian, (byte)21);
+                            this.guardian.level().broadcastEntityEvent(this.guardian, (byte) 21);
                         }
                     } else if (this.attackTime >= this.guardian.getAttackDuration()) {
                         float f = 1.0F;
+
                         if (this.guardian.level().getDifficulty() == Difficulty.HARD) {
                             f += 2.0F;
                         }
@@ -430,9 +499,9 @@
                             f += 2.0F;
                         }
 
-                        livingEntity.hurt(this.guardian.damageSources().indirectMagic(this.guardian, this.guardian), f);
-                        livingEntity.hurt(this.guardian.damageSources().mobAttack(this.guardian), (float)this.guardian.getAttributeValue(Attributes.ATTACK_DAMAGE));
-                        this.guardian.setTarget((LivingEntity)null);
+                        entityliving.hurt(this.guardian.damageSources().indirectMagic(this.guardian, this.guardian), f);
+                        entityliving.hurt(this.guardian.damageSources().mobAttack(this.guardian), (float) this.guardian.getAttributeValue(Attributes.ATTACK_DAMAGE));
+                        this.guardian.setTarget((LivingEntity) null);
                     }
 
                     super.tick();
@@ -441,65 +510,16 @@
         }
     }
 
-    static class GuardianAttackSelector implements Predicate<LivingEntity> {
+    private static class GuardianAttackSelector implements Predicate<LivingEntity> {
+
         private final Guardian guardian;
 
         public GuardianAttackSelector(Guardian owner) {
             this.guardian = owner;
         }
 
-        @Override
-        public boolean test(@Nullable LivingEntity livingEntity) {
-            return (livingEntity instanceof Player || livingEntity instanceof Squid || livingEntity instanceof Axolotl) && livingEntity.distanceToSqr(this.guardian) > 9.0D;
-        }
-    }
-
-    static class GuardianMoveControl extends MoveControl {
-        private final Guardian guardian;
-
-        public GuardianMoveControl(Guardian guardian) {
-            super(guardian);
-            this.guardian = guardian;
-        }
-
-        @Override
-        public void tick() {
-            if (this.operation == MoveControl.Operation.MOVE_TO && !this.guardian.getNavigation().isDone()) {
-                Vec3 vec3 = new Vec3(this.wantedX - this.guardian.getX(), this.wantedY - this.guardian.getY(), this.wantedZ - this.guardian.getZ());
-                double d = vec3.length();
-                double e = vec3.x / d;
-                double f = vec3.y / d;
-                double g = vec3.z / d;
-                float h = (float)(Mth.atan2(vec3.z, vec3.x) * (double)(180F / (float)Math.PI)) - 90.0F;
-                this.guardian.setYRot(this.rotlerp(this.guardian.getYRot(), h, 90.0F));
-                this.guardian.yBodyRot = this.guardian.getYRot();
-                float i = (float)(this.speedModifier * this.guardian.getAttributeValue(Attributes.MOVEMENT_SPEED));
-                float j = Mth.lerp(0.125F, this.guardian.getSpeed(), i);
-                this.guardian.setSpeed(j);
-                double k = Math.sin((double)(this.guardian.tickCount + this.guardian.getId()) * 0.5D) * 0.05D;
-                double l = Math.cos((double)(this.guardian.getYRot() * ((float)Math.PI / 180F)));
-                double m = Math.sin((double)(this.guardian.getYRot() * ((float)Math.PI / 180F)));
-                double n = Math.sin((double)(this.guardian.tickCount + this.guardian.getId()) * 0.75D) * 0.05D;
-                this.guardian.setDeltaMovement(this.guardian.getDeltaMovement().add(k * l, n * (m + l) * 0.25D + (double)j * f * 0.1D, k * m));
-                LookControl lookControl = this.guardian.getLookControl();
-                double o = this.guardian.getX() + e * 2.0D;
-                double p = this.guardian.getEyeY() + f / d;
-                double q = this.guardian.getZ() + g * 2.0D;
-                double r = lookControl.getWantedX();
-                double s = lookControl.getWantedY();
-                double t = lookControl.getWantedZ();
-                if (!lookControl.isLookingAtTarget()) {
-                    r = o;
-                    s = p;
-                    t = q;
-                }
-
-                this.guardian.getLookControl().setLookAt(Mth.lerp(0.125D, r, o), Mth.lerp(0.125D, s, p), Mth.lerp(0.125D, t, q), 10.0F, 40.0F);
-                this.guardian.setMoving(true);
-            } else {
-                this.guardian.setSpeed(0.0F);
-                this.guardian.setMoving(false);
-            }
+        public boolean test(@Nullable LivingEntity entityliving) {
+            return (entityliving instanceof Player || entityliving instanceof Squid || entityliving instanceof Axolotl) && entityliving.distanceToSqr((Entity) this.guardian) > 9.0D;
         }
     }
 }
