--- a/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
+++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
@@ -40,19 +40,20 @@
 
         entitylightning.teleportAndSync(this.horse.locX(), this.horse.locY(), this.horse.locZ());
         entitylightning.setEffect(true);
-        worldserver.addEntity(entitylightning);
+        worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
         EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.horse);
 
-        entityskeleton.startRiding(this.horse);
-        worldserver.addAllEntities(entityskeleton);
+        if (entityskeleton != null) entityskeleton.startRiding(this.horse); // CraftBukkit
+        worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
 
         for (int i = 0; i < 3; ++i) {
             EntityHorseAbstract entityhorseabstract = this.a(difficultydamagescaler);
+            if (entityhorseabstract == null) continue; // CraftBukkit
             EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorseabstract);
 
-            entityskeleton1.startRiding(entityhorseabstract);
+            if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit
             entityhorseabstract.i(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D);
-            worldserver.addAllEntities(entityhorseabstract);
+            worldserver.addAllEntities(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
         }
 
     }
