--- a/net/minecraft/world/entity/raid/Raider.java
+++ b/net/minecraft/world/entity/raid/Raider.java
@@ -2,6 +2,7 @@
 
 import com.google.common.collect.Lists;
 import java.util.EnumSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
@@ -43,9 +44,10 @@
 import net.minecraft.world.phys.Vec3;
 
 public abstract class Raider extends PatrollingMonster {
+
     protected static final EntityDataAccessor<Boolean> IS_CELEBRATING = SynchedEntityData.defineId(Raider.class, EntityDataSerializers.BOOLEAN);
-    static final Predicate<ItemEntity> ALLOWED_ITEMS = (itemEntity) -> {
-        return !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && ItemStack.matches(itemEntity.getItem(), Raid.getLeaderBannerInstance());
+    static final Predicate<ItemEntity> ALLOWED_ITEMS = (entityitem) -> {
+        return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBannerInstance());
     };
     @Nullable
     protected Raid raid;
@@ -62,14 +64,14 @@
         super.registerGoals();
         this.goalSelector.addGoal(1, new Raider.ObtainRaidLeaderBannerGoal<>(this));
         this.goalSelector.addGoal(3, new PathfindToRaidGoal<>(this));
-        this.goalSelector.addGoal(4, new Raider.RaiderMoveThroughVillageGoal(this, (double)1.05F, 1));
+        this.goalSelector.addGoal(4, new Raider.RaiderMoveThroughVillageGoal(this, 1.0499999523162842D, 1));
         this.goalSelector.addGoal(5, new Raider.RaiderCelebration(this));
     }
 
     @Override
     protected void defineSynchedData() {
         super.defineSynchedData();
-        this.entityData.define(IS_CELEBRATING, false);
+        this.entityData.define(Raider.IS_CELEBRATING, false);
     }
 
     public abstract void applyRaidBuffs(int wave, boolean unused);
@@ -86,17 +88,20 @@
     public void aiStep() {
         if (this.level instanceof ServerLevel && this.isAlive()) {
             Raid raid = this.getCurrentRaid();
+
             if (this.canJoinRaid()) {
                 if (raid == null) {
                     if (this.level.getGameTime() % 20L == 0L) {
-                        Raid raid2 = ((ServerLevel)this.level).getRaidAt(this.blockPosition());
-                        if (raid2 != null && Raids.canJoinRaid(this, raid2)) {
-                            raid2.joinRaid(raid2.getGroupsSpawned(), this, (BlockPos)null, true);
+                        Raid raid1 = ((ServerLevel) this.level).getRaidAt(this.blockPosition());
+
+                        if (raid1 != null && Raids.canJoinRaid(this, raid1)) {
+                            raid1.joinRaid(raid1.getGroupsSpawned(), this, (BlockPos) null, true);
                         }
                     }
                 } else {
-                    LivingEntity livingEntity = this.getTarget();
-                    if (livingEntity != null && (livingEntity.getType() == EntityType.PLAYER || livingEntity.getType() == EntityType.IRON_GOLEM)) {
+                    LivingEntity entityliving = this.getTarget();
+
+                    if (entityliving != null && (entityliving.getType() == EntityType.PLAYER || entityliving.getType() == EntityType.IRON_GOLEM)) {
                         this.noActionTime = 0;
                     }
                 }
@@ -116,6 +121,7 @@
         if (this.level instanceof ServerLevel) {
             Entity entity = damageSource.getEntity();
             Raid raid = this.getCurrentRaid();
+
             if (raid != null) {
                 if (this.isPatrolLeader()) {
                     raid.removeLeader(this.getWave());
@@ -128,33 +134,38 @@
                 raid.removeFromRaid(this, false);
             }
 
-            if (this.isPatrolLeader() && raid == null && ((ServerLevel)this.level).getRaidAt(this.blockPosition()) == null) {
-                ItemStack itemStack = this.getItemBySlot(EquipmentSlot.HEAD);
-                Player player = null;
+            if (this.isPatrolLeader() && raid == null && ((ServerLevel) this.level).getRaidAt(this.blockPosition()) == null) {
+                ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
+                Player entityhuman = null;
+
                 if (entity instanceof Player) {
-                    player = (Player)entity;
+                    entityhuman = (Player) entity;
                 } else if (entity instanceof Wolf) {
-                    Wolf wolf = (Wolf)entity;
-                    LivingEntity livingEntity = wolf.getOwner();
-                    if (wolf.isTame() && livingEntity instanceof Player) {
-                        player = (Player)livingEntity;
+                    Wolf entitywolf = (Wolf) entity;
+                    LivingEntity entityliving = entitywolf.getOwner();
+
+                    if (entitywolf.isTame() && entityliving instanceof Player) {
+                        entityhuman = (Player) entityliving;
                     }
                 }
 
-                if (!itemStack.isEmpty() && ItemStack.matches(itemStack, Raid.getLeaderBannerInstance()) && player != null) {
-                    MobEffectInstance mobEffectInstance = player.getEffect(MobEffects.BAD_OMEN);
-                    int i = 1;
-                    if (mobEffectInstance != null) {
-                        i += mobEffectInstance.getAmplifier();
-                        player.removeEffectNoUpdate(MobEffects.BAD_OMEN);
+                if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance()) && entityhuman != null) {
+                    MobEffectInstance mobeffect = entityhuman.getEffect(MobEffects.BAD_OMEN);
+                    byte b0 = 1;
+                    int i;
+
+                    if (mobeffect != null) {
+                        i = b0 + mobeffect.getAmplifier();
+                        entityhuman.removeEffectNoUpdate(MobEffects.BAD_OMEN);
                     } else {
-                        --i;
+                        i = b0 - 1;
                     }
 
-                    i = Mth.clamp(i, 0, 4);
-                    MobEffectInstance mobEffectInstance2 = new MobEffectInstance(MobEffects.BAD_OMEN, 120000, i, false, false, true);
+                    i = Mth.clamp(i, (int) 0, (int) 4);
+                    MobEffectInstance mobeffect1 = new MobEffectInstance(MobEffects.BAD_OMEN, 120000, i, false, false, true);
+
                     if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) {
-                        player.addEffect(mobEffectInstance2);
+                        entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
                     }
                 }
             }
@@ -190,11 +201,11 @@
     }
 
     public boolean isCelebrating() {
-        return this.entityData.get(IS_CELEBRATING);
+        return (Boolean) this.entityData.get(Raider.IS_CELEBRATING);
     }
 
     public void setCelebrating(boolean celebrating) {
-        this.entityData.set(IS_CELEBRATING, celebrating);
+        this.entityData.set(Raider.IS_CELEBRATING, celebrating);
     }
 
     @Override
@@ -215,7 +226,7 @@
         this.canJoinRaid = nbt.getBoolean("CanJoinRaid");
         if (nbt.contains("RaidId", 3)) {
             if (this.level instanceof ServerLevel) {
-                this.raid = ((ServerLevel)this.level).getRaids().get(nbt.getInt("RaidId"));
+                this.raid = ((ServerLevel) this.level).getRaids().get(nbt.getInt("RaidId"));
             }
 
             if (this.raid != null) {
@@ -230,19 +241,28 @@
 
     @Override
     protected void pickUpItem(ItemEntity item) {
-        ItemStack itemStack = item.getItem();
-        boolean bl = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
-        if (this.hasActiveRaid() && !bl && ItemStack.matches(itemStack, Raid.getLeaderBannerInstance())) {
-            EquipmentSlot equipmentSlot = EquipmentSlot.HEAD;
-            ItemStack itemStack2 = this.getItemBySlot(equipmentSlot);
-            double d = (double)this.getEquipmentDropChance(equipmentSlot);
-            if (!itemStack2.isEmpty() && (double)Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d) {
-                this.spawnAtLocation(itemStack2);
+        ItemStack itemstack = item.getItem();
+        boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
+
+        if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) {
+            // Paper start
+            if (org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) {
+                return;
+            }
+            // Paper end
+            EquipmentSlot enumitemslot = EquipmentSlot.HEAD;
+            ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
+            double d0 = (double) this.getEquipmentDropChance(enumitemslot);
+
+            if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
+                this.forceDrops = true; // Paper
+                this.spawnAtLocation(itemstack1);
+                this.forceDrops = false; // Paper
             }
 
             this.onItemPickup(item);
-            this.setItemSlot(equipmentSlot, itemStack);
-            this.take(item, itemStack.getCount());
+            this.setItemSlot(enumitemslot, itemstack);
+            this.take(item, itemstack.getCount());
             item.discard();
             this.getCurrentRaid().setLeader(this.getWave(), this);
             this.setPatrolLeader(true);
@@ -288,89 +308,28 @@
 
     public abstract SoundEvent getCelebrateSound();
 
-    protected class HoldGroundAttackGoal extends Goal {
-        private final Raider mob;
-        private final float hostileRadiusSqr;
-        public final TargetingConditions shoutTargeting = TargetingConditions.forNonCombat().range(8.0D).ignoreLineOfSight().ignoreInvisibilityTesting();
-
-        public HoldGroundAttackGoal(AbstractIllager illager, float distance) {
-            this.mob = illager;
-            this.hostileRadiusSqr = distance * distance;
-            this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
-        }
-
-        @Override
-        public boolean canUse() {
-            LivingEntity livingEntity = this.mob.getLastHurtByMob();
-            return this.mob.getCurrentRaid() == null && this.mob.isPatrolling() && this.mob.getTarget() != null && !this.mob.isAggressive() && (livingEntity == null || livingEntity.getType() != EntityType.PLAYER);
-        }
-
-        @Override
-        public void start() {
-            super.start();
-            this.mob.getNavigation().stop();
-
-            for(Raider raider : this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) {
-                raider.setTarget(this.mob.getTarget());
-            }
-
-        }
-
-        @Override
-        public void stop() {
-            super.stop();
-            LivingEntity livingEntity = this.mob.getTarget();
-            if (livingEntity != null) {
-                for(Raider raider : this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D))) {
-                    raider.setTarget(livingEntity);
-                    raider.setAggressive(true);
-                }
-
-                this.mob.setAggressive(true);
-            }
-
-        }
-
-        @Override
-        public boolean requiresUpdateEveryTick() {
-            return true;
-        }
-
-        @Override
-        public void tick() {
-            LivingEntity livingEntity = this.mob.getTarget();
-            if (livingEntity != null) {
-                if (this.mob.distanceToSqr(livingEntity) > (double)this.hostileRadiusSqr) {
-                    this.mob.getLookControl().setLookAt(livingEntity, 30.0F, 30.0F);
-                    if (this.mob.random.nextInt(50) == 0) {
-                        this.mob.playAmbientSound();
-                    }
-                } else {
-                    this.mob.setAggressive(true);
-                }
-
-                super.tick();
-            }
-        }
-    }
-
     public class ObtainRaidLeaderBannerGoal<T extends Raider> extends Goal {
+
         private final T mob;
 
-        public ObtainRaidLeaderBannerGoal(T actor) {
-            this.mob = actor;
+        public ObtainRaidLeaderBannerGoal(T entityraider) { // CraftBukkit - decompile error
+            this.mob = entityraider;
             this.setFlags(EnumSet.of(Goal.Flag.MOVE));
         }
 
         @Override
         public boolean canUse() {
+            if (!this.mob.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
             Raid raid = this.mob.getCurrentRaid();
+
             if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) {
-                Raider raider = raid.getLeader(this.mob.getWave());
-                if (raider == null || !raider.isAlive()) {
+                Raider entityraider = raid.getLeader(this.mob.getWave());
+
+                if (entityraider == null || !entityraider.isAlive()) {
                     List<ItemEntity> list = this.mob.level.getEntitiesOfClass(ItemEntity.class, this.mob.getBoundingBox().inflate(16.0D, 8.0D, 16.0D), Raider.ALLOWED_ITEMS);
+
                     if (!list.isEmpty()) {
-                        return this.mob.getNavigation().moveTo(list.get(0), (double)1.15F);
+                        return this.mob.getNavigation().moveTo((Entity) list.get(0), 1.149999976158142D);
                     }
                 }
 
@@ -384,55 +343,17 @@
         public void tick() {
             if (this.mob.getNavigation().getTargetPos().closerToCenterThan(this.mob.position(), 1.414D)) {
                 List<ItemEntity> list = this.mob.level.getEntitiesOfClass(ItemEntity.class, this.mob.getBoundingBox().inflate(4.0D, 4.0D, 4.0D), Raider.ALLOWED_ITEMS);
+
                 if (!list.isEmpty()) {
-                    this.mob.pickUpItem(list.get(0));
+                    this.mob.pickUpItem((ItemEntity) list.get(0));
                 }
             }
 
         }
     }
 
-    public class RaiderCelebration extends Goal {
-        private final Raider mob;
-
-        RaiderCelebration(Raider raider) {
-            this.mob = raider;
-            this.setFlags(EnumSet.of(Goal.Flag.MOVE));
-        }
-
-        @Override
-        public boolean canUse() {
-            Raid raid = this.mob.getCurrentRaid();
-            return this.mob.isAlive() && this.mob.getTarget() == null && raid != null && raid.isLoss();
-        }
-
-        @Override
-        public void start() {
-            this.mob.setCelebrating(true);
-            super.start();
-        }
-
-        @Override
-        public void stop() {
-            this.mob.setCelebrating(false);
-            super.stop();
-        }
-
-        @Override
-        public void tick() {
-            if (!this.mob.isSilent() && this.mob.random.nextInt(this.adjustedTickDelay(100)) == 0) {
-                Raider.this.playSound(Raider.this.getCelebrateSound(), Raider.this.getSoundVolume(), Raider.this.getVoicePitch());
-            }
-
-            if (!this.mob.isPassenger() && this.mob.random.nextInt(this.adjustedTickDelay(50)) == 0) {
-                this.mob.getJumpControl().jump();
-            }
-
-            super.tick();
-        }
-    }
+    private static class RaiderMoveThroughVillageGoal extends Goal {
 
-    static class RaiderMoveThroughVillageGoal extends Goal {
         private final Raider raider;
         private final double speedModifier;
         private BlockPos poiPos;
@@ -458,31 +379,28 @@
         }
 
         private boolean hasSuitablePoi() {
-            ServerLevel serverLevel = (ServerLevel)this.raider.level;
-            BlockPos blockPos = this.raider.blockPosition();
-            Optional<BlockPos> optional = serverLevel.getPoiManager().getRandom((holder) -> {
+            ServerLevel worldserver = (ServerLevel) this.raider.level;
+            BlockPos blockposition = this.raider.blockPosition();
+            Optional<BlockPos> optional = worldserver.getPoiManager().getRandom((holder) -> {
                 return holder.is(PoiTypes.HOME);
-            }, this::hasNotVisited, PoiManager.Occupancy.ANY, blockPos, 48, this.raider.random);
+            }, this::hasNotVisited, PoiManager.Occupancy.ANY, blockposition, 48, this.raider.random);
+
             if (!optional.isPresent()) {
                 return false;
             } else {
-                this.poiPos = optional.get().immutable();
+                this.poiPos = ((BlockPos) optional.get()).immutable();
                 return true;
             }
         }
 
         @Override
         public boolean canContinueToUse() {
-            if (this.raider.getNavigation().isDone()) {
-                return false;
-            } else {
-                return this.raider.getTarget() == null && !this.poiPos.closerToCenterThan(this.raider.position(), (double)(this.raider.getBbWidth() + (float)this.distanceToPoi)) && !this.stuck;
-            }
+            return this.raider.getNavigation().isDone() ? false : this.raider.getTarget() == null && !this.poiPos.closerToCenterThan(this.raider.position(), (double) (this.raider.getBbWidth() + (float) this.distanceToPoi)) && !this.stuck;
         }
 
         @Override
         public void stop() {
-            if (this.poiPos.closerToCenterThan(this.raider.position(), (double)this.distanceToPoi)) {
+            if (this.poiPos.closerToCenterThan(this.raider.position(), (double) this.distanceToPoi)) {
                 this.visited.add(this.poiPos);
             }
 
@@ -492,37 +410,44 @@
         public void start() {
             super.start();
             this.raider.setNoActionTime(0);
-            this.raider.getNavigation().moveTo((double)this.poiPos.getX(), (double)this.poiPos.getY(), (double)this.poiPos.getZ(), this.speedModifier);
+            this.raider.getNavigation().moveTo((double) this.poiPos.getX(), (double) this.poiPos.getY(), (double) this.poiPos.getZ(), this.speedModifier);
             this.stuck = false;
         }
 
         @Override
         public void tick() {
             if (this.raider.getNavigation().isDone()) {
-                Vec3 vec3 = Vec3.atBottomCenterOf(this.poiPos);
-                Vec3 vec32 = DefaultRandomPos.getPosTowards(this.raider, 16, 7, vec3, (double)((float)Math.PI / 10F));
-                if (vec32 == null) {
-                    vec32 = DefaultRandomPos.getPosTowards(this.raider, 8, 7, vec3, (double)((float)Math.PI / 2F));
+                Vec3 vec3d = Vec3.atBottomCenterOf(this.poiPos);
+                Vec3 vec3d1 = DefaultRandomPos.getPosTowards(this.raider, 16, 7, vec3d, 0.3141592741012573D);
+
+                if (vec3d1 == null) {
+                    vec3d1 = DefaultRandomPos.getPosTowards(this.raider, 8, 7, vec3d, 1.5707963705062866D);
                 }
 
-                if (vec32 == null) {
+                if (vec3d1 == null) {
                     this.stuck = true;
                     return;
                 }
 
-                this.raider.getNavigation().moveTo(vec32.x, vec32.y, vec32.z, this.speedModifier);
+                this.raider.getNavigation().moveTo(vec3d1.x, vec3d1.y, vec3d1.z, this.speedModifier);
             }
 
         }
 
         private boolean hasNotVisited(BlockPos pos) {
-            for(BlockPos blockPos : this.visited) {
-                if (Objects.equals(pos, blockPos)) {
-                    return false;
+            Iterator iterator = this.visited.iterator();
+
+            BlockPos blockposition1;
+
+            do {
+                if (!iterator.hasNext()) {
+                    return true;
                 }
-            }
 
-            return true;
+                blockposition1 = (BlockPos) iterator.next();
+            } while (!Objects.equals(pos, blockposition1));
+
+            return false;
         }
 
         private void updateVisited() {
@@ -532,4 +457,125 @@
 
         }
     }
+
+    public class RaiderCelebration extends Goal {
+
+        private final Raider mob;
+
+        RaiderCelebration(Raider entityraider) {
+            this.mob = entityraider;
+            this.setFlags(EnumSet.of(Goal.Flag.MOVE));
+        }
+
+        @Override
+        public boolean canUse() {
+            Raid raid = this.mob.getCurrentRaid();
+
+            return this.mob.isAlive() && this.mob.getTarget() == null && raid != null && raid.isLoss();
+        }
+
+        @Override
+        public void start() {
+            this.mob.setCelebrating(true);
+            super.start();
+        }
+
+        @Override
+        public void stop() {
+            this.mob.setCelebrating(false);
+            super.stop();
+        }
+
+        @Override
+        public void tick() {
+            if (!this.mob.isSilent() && this.mob.random.nextInt(this.adjustedTickDelay(100)) == 0) {
+                Raider.this.playSound(Raider.this.getCelebrateSound(), Raider.this.getSoundVolume(), Raider.this.getVoicePitch());
+            }
+
+            if (!this.mob.isPassenger() && this.mob.random.nextInt(this.adjustedTickDelay(50)) == 0) {
+                this.mob.getJumpControl().jump();
+            }
+
+            super.tick();
+        }
+    }
+
+    protected class HoldGroundAttackGoal extends Goal {
+
+        private final Raider mob;
+        private final float hostileRadiusSqr;
+        public final TargetingConditions shoutTargeting = TargetingConditions.forNonCombat().range(8.0D).ignoreLineOfSight().ignoreInvisibilityTesting();
+
+        public HoldGroundAttackGoal(AbstractIllager entityillagerabstract, float f) {
+            this.mob = entityillagerabstract;
+            this.hostileRadiusSqr = f * f;
+            this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
+        }
+
+        @Override
+        public boolean canUse() {
+            LivingEntity entityliving = this.mob.getLastHurtByMob();
+
+            return this.mob.getCurrentRaid() == null && this.mob.isPatrolling() && this.mob.getTarget() != null && !this.mob.isAggressive() && (entityliving == null || entityliving.getType() != EntityType.PLAYER);
+        }
+
+        @Override
+        public void start() {
+            super.start();
+            this.mob.getNavigation().stop();
+            List<Raider> list = this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D));
+            Iterator iterator = list.iterator();
+
+            while (iterator.hasNext()) {
+                Raider entityraider = (Raider) iterator.next();
+
+                entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
+            }
+
+        }
+
+        @Override
+        public void stop() {
+            super.stop();
+            LivingEntity entityliving = this.mob.getTarget();
+
+            if (entityliving != null) {
+                List<Raider> list = this.mob.level.getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0D, 8.0D, 8.0D));
+                Iterator iterator = list.iterator();
+
+                while (iterator.hasNext()) {
+                    Raider entityraider = (Raider) iterator.next();
+
+                    entityraider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit
+                    entityraider.setAggressive(true);
+                }
+
+                this.mob.setAggressive(true);
+            }
+
+        }
+
+        @Override
+        public boolean requiresUpdateEveryTick() {
+            return true;
+        }
+
+        @Override
+        public void tick() {
+            LivingEntity entityliving = this.mob.getTarget();
+
+            if (entityliving != null) {
+                if (this.mob.distanceToSqr((Entity) entityliving) > (double) this.hostileRadiusSqr) {
+                    this.mob.getLookControl().setLookAt(entityliving, 30.0F, 30.0F);
+                    if (this.mob.random.nextInt(50) == 0) {
+                        this.mob.playAmbientSound();
+                    }
+                } else {
+                    this.mob.setAggressive(true);
+                }
+
+                super.tick();
+            }
+        }
+    }
 }
