--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -48,6 +48,7 @@
 import net.minecraft.world.phys.Vec3;
 
 public class IronGolem extends AbstractGolem implements NeutralMob {
+
     protected static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(IronGolem.class, EntityDataSerializers.BYTE);
     private static final int IRON_INGOT_HEAL_AMOUNT = 25;
     private int attackAnimationTick;
@@ -63,34 +64,30 @@
 
     @Override
     protected void registerGoals() {
-        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true));
-        this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F));
-        this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false));
-        this.goalSelector.addGoal(4, new GolemRandomStrollInVillageGoal(this, 0.6));
+        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, true));
+        this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9D, 32.0F));
+        this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6D, false));
+        this.goalSelector.addGoal(4, new GolemRandomStrollInVillageGoal(this, 0.6D));
         this.goalSelector.addGoal(5, new OfferFlowerGoal(this));
         this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, Player.class, 6.0F));
         this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
         this.targetSelector.addGoal(1, new DefendVillageTargetGoal(this));
-        this.targetSelector.addGoal(2, new HurtByTargetGoal(this));
+        this.targetSelector.addGoal(2, new HurtByTargetGoal(this, new Class[0]));
         this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
-        this.targetSelector
-            .addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 5, false, false, entity -> entity instanceof Enemy && !(entity instanceof Creeper)));
+        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 5, false, false, (entityliving) -> {
+            return entityliving instanceof Enemy && !(entityliving instanceof Creeper);
+        }));
         this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, false));
     }
 
     @Override
     protected void defineSynchedData(SynchedEntityData.Builder builder) {
         super.defineSynchedData(builder);
-        builder.define(DATA_FLAGS_ID, (byte)0);
+        builder.define(IronGolem.DATA_FLAGS_ID, (byte) 0);
     }
 
     public static AttributeSupplier.Builder createAttributes() {
-        return Mob.createMobAttributes()
-            .add(Attributes.MAX_HEALTH, 100.0)
-            .add(Attributes.MOVEMENT_SPEED, 0.25)
-            .add(Attributes.KNOCKBACK_RESISTANCE, 1.0)
-            .add(Attributes.ATTACK_DAMAGE, 15.0)
-            .add(Attributes.STEP_HEIGHT, 1.0);
+        return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 100.0D).add(Attributes.MOVEMENT_SPEED, 0.25D).add(Attributes.KNOCKBACK_RESISTANCE, 1.0D).add(Attributes.ATTACK_DAMAGE, 15.0D).add(Attributes.STEP_HEIGHT, 1.0D);
     }
 
     @Override
@@ -101,7 +98,7 @@
     @Override
     protected void doPush(Entity entity) {
         if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) {
-            this.setTarget((LivingEntity)entity);
+            this.setTarget((LivingEntity) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
         }
 
         super.doPush(entity);
@@ -111,26 +108,27 @@
     public void aiStep() {
         super.aiStep();
         if (this.attackAnimationTick > 0) {
-            this.attackAnimationTick--;
+            --this.attackAnimationTick;
         }
 
         if (this.offerFlowerTick > 0) {
-            this.offerFlowerTick--;
+            --this.offerFlowerTick;
         }
 
         if (!this.level().isClientSide) {
-            this.updatePersistentAnger((ServerLevel)this.level(), true);
+            this.updatePersistentAnger((ServerLevel) this.level(), true);
         }
+
     }
 
     @Override
     public boolean canSpawnSprintParticle() {
-        return this.getDeltaMovement().horizontalDistanceSqr() > 2.5000003E-7F && this.random.nextInt(5) == 0;
+        return this.getDeltaMovement().horizontalDistanceSqr() > 2.500000277905201E-7D && this.random.nextInt(5) == 0;
     }
 
     @Override
     public boolean canAttackType(EntityType<?> type) {
-        return (!this.isPlayerCreated() || type != EntityType.PLAYER) && type != EntityType.CREEPER && super.canAttackType(type);
+        return this.isPlayerCreated() && type == EntityType.PLAYER ? false : (type == EntityType.CREEPER ? false : super.canAttackType(type));
     }
 
     @Override
@@ -149,7 +147,7 @@
 
     @Override
     public void startPersistentAngerTimer() {
-        this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random));
+        this.setRemainingPersistentAngerTime(IronGolem.PERSISTENT_ANGER_TIME.sample(this.random));
     }
 
     @Override
@@ -174,39 +172,56 @@
     }
 
     private float getAttackDamage() {
-        return (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
+        return (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
     }
 
     @Override
     public boolean doHurtTarget(Entity target) {
         this.attackAnimationTick = 10;
-        this.level().broadcastEntityEvent(this, (byte)4);
+        this.level().broadcastEntityEvent(this, (byte) 4);
         float f = this.getAttackDamage();
-        float g = (int)f > 0 ? f / 2.0F + (float)this.random.nextInt((int)f) : f;
-        DamageSource damageSource = this.damageSources().mobAttack(this);
-        boolean bl = target.hurt(damageSource, g);
-        if (bl) {
-            double d = target instanceof LivingEntity livingEntity ? livingEntity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) : 0.0;
-            double e = Math.max(0.0, 1.0 - d);
-            target.setDeltaMovement(target.getDeltaMovement().add(0.0, 0.4F * e, 0.0));
-            if (this.level() instanceof ServerLevel serverLevel) {
-                EnchantmentHelper.doPostAttackEffects(serverLevel, target, damageSource);
+        float f1 = (int) f > 0 ? f / 2.0F + (float) this.random.nextInt((int) f) : f;
+        DamageSource damagesource = this.damageSources().mobAttack(this);
+        boolean flag = target.hurt(damagesource, f1);
+
+        if (flag) {
+            double d0;
+
+            if (target instanceof LivingEntity) {
+                LivingEntity entityliving = (LivingEntity) target;
+
+                d0 = entityliving.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
+            } else {
+                d0 = 0.0D;
+            }
+
+            double d1 = d0;
+            double d2 = Math.max(0.0D, 1.0D - d1);
+
+            target.setDeltaMovement(target.getDeltaMovement().add(0.0D, 0.4000000059604645D * d2, 0.0D));
+            Level world = this.level();
+
+            if (world instanceof ServerLevel) {
+                ServerLevel worldserver = (ServerLevel) world;
+
+                EnchantmentHelper.doPostAttackEffects(worldserver, target, damagesource);
             }
         }
 
         this.playSound(SoundEvents.IRON_GOLEM_ATTACK, 1.0F, 1.0F);
-        return bl;
+        return flag;
     }
 
     @Override
     public boolean hurt(DamageSource source, float amount) {
-        Crackiness.Level level = this.getCrackiness();
-        boolean bl = super.hurt(source, amount);
-        if (bl && this.getCrackiness() != level) {
+        Crackiness.Level crackiness_a = this.getCrackiness();
+        boolean flag = super.hurt(source, amount);
+
+        if (flag && this.getCrackiness() != crackiness_a) {
             this.playSound(SoundEvents.IRON_GOLEM_DAMAGE, 1.0F, 1.0F);
         }
 
-        return bl;
+        return flag;
     }
 
     public Crackiness.Level getCrackiness() {
@@ -225,6 +240,7 @@
         } else {
             super.handleEntityEvent(status);
         }
+
     }
 
     public int getAttackAnimationTick() {
@@ -234,11 +250,12 @@
     public void offerFlower(boolean lookingAtVillager) {
         if (lookingAtVillager) {
             this.offerFlowerTick = 400;
-            this.level().broadcastEntityEvent(this, (byte)11);
+            this.level().broadcastEntityEvent(this, (byte) 11);
         } else {
             this.offerFlowerTick = 0;
-            this.level().broadcastEntityEvent(this, (byte)34);
+            this.level().broadcastEntityEvent(this, (byte) 34);
         }
+
     }
 
     @Override
@@ -253,18 +270,21 @@
 
     @Override
     protected InteractionResult mobInteract(Player player, InteractionHand hand) {
-        ItemStack itemStack = player.getItemInHand(hand);
-        if (!itemStack.is(Items.IRON_INGOT)) {
+        ItemStack itemstack = player.getItemInHand(hand);
+
+        if (!itemstack.is(Items.IRON_INGOT)) {
             return InteractionResult.PASS;
         } else {
             float f = this.getHealth();
+
             this.heal(25.0F);
             if (this.getHealth() == f) {
                 return InteractionResult.PASS;
             } else {
-                float g = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F;
-                this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, g);
-                itemStack.consume(1, player);
+                float f1 = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F;
+
+                this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f1);
+                itemstack.consume(1, player);
                 return InteractionResult.sidedSuccess(this.level().isClientSide);
             }
         }
@@ -280,16 +300,18 @@
     }
 
     public boolean isPlayerCreated() {
-        return (this.entityData.get(DATA_FLAGS_ID) & 1) != 0;
+        return ((Byte) this.entityData.get(IronGolem.DATA_FLAGS_ID) & 1) != 0;
     }
 
     public void setPlayerCreated(boolean playerCreated) {
-        byte b = this.entityData.get(DATA_FLAGS_ID);
+        byte b0 = (Byte) this.entityData.get(IronGolem.DATA_FLAGS_ID);
+
         if (playerCreated) {
-            this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1));
+            this.entityData.set(IronGolem.DATA_FLAGS_ID, (byte) (b0 | 1));
         } else {
-            this.entityData.set(DATA_FLAGS_ID, (byte)(b & -2));
+            this.entityData.set(IronGolem.DATA_FLAGS_ID, (byte) (b0 & -2));
         }
+
     }
 
     @Override
@@ -299,29 +321,28 @@
 
     @Override
     public boolean checkSpawnObstruction(LevelReader world) {
-        BlockPos blockPos = this.blockPosition();
-        BlockPos blockPos2 = blockPos.below();
-        BlockState blockState = world.getBlockState(blockPos2);
-        if (!blockState.entityCanStandOn(world, blockPos2, this)) {
+        BlockPos blockposition = this.blockPosition();
+        BlockPos blockposition1 = blockposition.below();
+        BlockState iblockdata = world.getBlockState(blockposition1);
+
+        if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper - Add option to allow iron golems to spawn in air
             return false;
         } else {
-            for (int i = 1; i < 3; i++) {
-                BlockPos blockPos3 = blockPos.above(i);
-                BlockState blockState2 = world.getBlockState(blockPos3);
-                if (!NaturalSpawner.isValidEmptySpawnBlock(world, blockPos3, blockState2, blockState2.getFluidState(), EntityType.IRON_GOLEM)) {
+            for (int i = 1; i < 3; ++i) {
+                BlockPos blockposition2 = blockposition.above(i);
+                BlockState iblockdata1 = world.getBlockState(blockposition2);
+
+                if (!NaturalSpawner.isValidEmptySpawnBlock(world, blockposition2, iblockdata1, iblockdata1.getFluidState(), EntityType.IRON_GOLEM)) {
                     return false;
                 }
             }
 
-            return NaturalSpawner.isValidEmptySpawnBlock(
-                    world, blockPos, world.getBlockState(blockPos), Fluids.EMPTY.defaultFluidState(), EntityType.IRON_GOLEM
-                )
-                && world.isUnobstructed(this);
+            return NaturalSpawner.isValidEmptySpawnBlock(world, blockposition, world.getBlockState(blockposition), Fluids.EMPTY.defaultFluidState(), EntityType.IRON_GOLEM) && world.isUnobstructed(this);
         }
     }
 
     @Override
     public Vec3 getLeashOffset() {
-        return new Vec3(0.0, (double)(0.875F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F));
+        return new Vec3(0.0D, (double) (0.875F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F));
     }
 }
