--- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
@@ -8,6 +8,7 @@
 import net.minecraft.world.entity.EquipmentSlot;
 import net.minecraft.world.entity.LightningBolt;
 import net.minecraft.world.entity.MobSpawnType;
+import net.minecraft.world.entity.SpawnGroupData;
 import net.minecraft.world.entity.ai.goal.Goal;
 import net.minecraft.world.entity.monster.Skeleton;
 import net.minecraft.world.item.ItemStack;
@@ -17,7 +18,9 @@
 import net.minecraft.world.item.enchantment.providers.VanillaEnchantmentProviders;
 
 public class SkeletonTrapGoal extends Goal {
+
     private final SkeletonHorse horse;
+    private java.util.List<org.bukkit.entity.HumanEntity> eligiblePlayers; // Paper
 
     public SkeletonTrapGoal(SkeletonHorse skeletonHorse) {
         this.horse = skeletonHorse;
@@ -25,81 +28,89 @@
 
     @Override
     public boolean canUse() {
-        return this.horse.level().hasNearbyAlivePlayer(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0);
+        return !(eligiblePlayers = this.horse.level().findNearbyBukkitPlayers(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D, net.minecraft.world.entity.EntitySelector.PLAYER_AFFECTS_SPAWNING)).isEmpty(); // Paper - Affects Spawning API & SkeletonHorseTrapEvent
     }
 
     @Override
     public void tick() {
-        ServerLevel serverLevel = (ServerLevel)this.horse.level();
-        DifficultyInstance difficultyInstance = serverLevel.getCurrentDifficultyAt(this.horse.blockPosition());
+        ServerLevel worldserver = (ServerLevel) this.horse.level();
+        if (!new com.destroystokyo.paper.event.entity.SkeletonHorseTrapEvent((org.bukkit.entity.SkeletonHorse) this.horse.getBukkitEntity(), eligiblePlayers).callEvent()) return; // Paper
+        DifficultyInstance difficultydamagescaler = worldserver.getCurrentDifficultyAt(this.horse.blockPosition());
+
         this.horse.setTrap(false);
         this.horse.setTamed(true);
         this.horse.setAge(0);
-        LightningBolt lightningBolt = EntityType.LIGHTNING_BOLT.create(serverLevel);
-        if (lightningBolt != null) {
-            lightningBolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
-            lightningBolt.setVisualOnly(true);
-            serverLevel.addFreshEntity(lightningBolt);
-            Skeleton skeleton = this.createSkeleton(difficultyInstance, this.horse);
-            if (skeleton != null) {
-                skeleton.startRiding(this.horse);
-                serverLevel.addFreshEntityWithPassengers(skeleton);
+        LightningBolt entitylightning = (LightningBolt) EntityType.LIGHTNING_BOLT.create(worldserver);
 
-                for (int i = 0; i < 3; i++) {
-                    AbstractHorse abstractHorse = this.createHorse(difficultyInstance);
-                    if (abstractHorse != null) {
-                        Skeleton skeleton2 = this.createSkeleton(difficultyInstance, abstractHorse);
-                        if (skeleton2 != null) {
-                            skeleton2.startRiding(abstractHorse);
-                            abstractHorse.push(this.horse.getRandom().triangle(0.0, 1.1485), 0.0, this.horse.getRandom().triangle(0.0, 1.1485));
-                            serverLevel.addFreshEntityWithPassengers(abstractHorse);
+        if (entitylightning != null) {
+            entitylightning.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
+            entitylightning.setVisualOnly(true);
+            worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
+            Skeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse);
+
+            if (entityskeleton != null) {
+                entityskeleton.startRiding(this.horse);
+                worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
+
+                for (int i = 0; i < 3; ++i) {
+                    AbstractHorse entityhorseabstract = this.createHorse(difficultydamagescaler);
+
+                    if (entityhorseabstract != null) {
+                        Skeleton entityskeleton1 = this.createSkeleton(difficultydamagescaler, entityhorseabstract);
+
+                        if (entityskeleton1 != null) {
+                            entityskeleton1.startRiding(entityhorseabstract);
+                            entityhorseabstract.push(this.horse.getRandom().triangle(0.0D, 1.1485D), 0.0D, this.horse.getRandom().triangle(0.0D, 1.1485D));
+                            worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
                         }
                     }
                 }
+
             }
         }
     }
 
     @Nullable
     private AbstractHorse createHorse(DifficultyInstance localDifficulty) {
-        SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this.horse.level());
-        if (skeletonHorse != null) {
-            skeletonHorse.finalizeSpawn((ServerLevel)this.horse.level(), localDifficulty, MobSpawnType.TRIGGERED, null);
-            skeletonHorse.setPos(this.horse.getX(), this.horse.getY(), this.horse.getZ());
-            skeletonHorse.invulnerableTime = 60;
-            skeletonHorse.setPersistenceRequired();
-            skeletonHorse.setTamed(true);
-            skeletonHorse.setAge(0);
+        SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create(this.horse.level());
+
+        if (entityhorseskeleton != null) {
+            entityhorseskeleton.finalizeSpawn((ServerLevel) this.horse.level(), localDifficulty, MobSpawnType.TRIGGERED, (SpawnGroupData) null);
+            entityhorseskeleton.setPos(this.horse.getX(), this.horse.getY(), this.horse.getZ());
+            entityhorseskeleton.invulnerableTime = 60;
+            entityhorseskeleton.setPersistenceRequired();
+            entityhorseskeleton.setTamed(true);
+            entityhorseskeleton.setAge(0);
         }
 
-        return skeletonHorse;
+        return entityhorseskeleton;
     }
 
     @Nullable
     private Skeleton createSkeleton(DifficultyInstance localDifficulty, AbstractHorse vehicle) {
-        Skeleton skeleton = EntityType.SKELETON.create(vehicle.level());
-        if (skeleton != null) {
-            skeleton.finalizeSpawn((ServerLevel)vehicle.level(), localDifficulty, MobSpawnType.TRIGGERED, null);
-            skeleton.setPos(vehicle.getX(), vehicle.getY(), vehicle.getZ());
-            skeleton.invulnerableTime = 60;
-            skeleton.setPersistenceRequired();
-            if (skeleton.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
-                skeleton.setItemSlot(EquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
+        Skeleton entityskeleton = (Skeleton) EntityType.SKELETON.create(vehicle.level());
+
+        if (entityskeleton != null) {
+            entityskeleton.finalizeSpawn((ServerLevel) vehicle.level(), localDifficulty, MobSpawnType.TRIGGERED, (SpawnGroupData) null);
+            entityskeleton.setPos(vehicle.getX(), vehicle.getY(), vehicle.getZ());
+            entityskeleton.invulnerableTime = 60;
+            entityskeleton.setPersistenceRequired();
+            if (entityskeleton.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
+                entityskeleton.setItemSlot(EquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
             }
 
-            this.enchant(skeleton, EquipmentSlot.MAINHAND, localDifficulty);
-            this.enchant(skeleton, EquipmentSlot.HEAD, localDifficulty);
+            this.enchant(entityskeleton, EquipmentSlot.MAINHAND, localDifficulty);
+            this.enchant(entityskeleton, EquipmentSlot.HEAD, localDifficulty);
         }
 
-        return skeleton;
+        return entityskeleton;
     }
 
     private void enchant(Skeleton rider, EquipmentSlot slot, DifficultyInstance localDifficulty) {
-        ItemStack itemStack = rider.getItemBySlot(slot);
-        itemStack.set(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY);
-        EnchantmentHelper.enchantItemFromProvider(
-            itemStack, rider.level().registryAccess(), VanillaEnchantmentProviders.MOB_SPAWN_EQUIPMENT, localDifficulty, rider.getRandom()
-        );
-        rider.setItemSlot(slot, itemStack);
+        ItemStack itemstack = rider.getItemBySlot(slot);
+
+        itemstack.set(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY);
+        EnchantmentHelper.enchantItemFromProvider(itemstack, rider.level().registryAccess(), VanillaEnchantmentProviders.MOB_SPAWN_EQUIPMENT, localDifficulty, rider.getRandom());
+        rider.setItemSlot(slot, itemstack);
     }
 }
