summaryrefslogtreecommitdiffstats
path: root/nms-patches/PathfinderGoalHorseTrap.patch
blob: c20e929d7abd5bae9fc4f1f6e85911c26bd10d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- a/net/minecraft/server/PathfinderGoalHorseTrap.java
+++ b/net/minecraft/server/PathfinderGoalHorseTrap.java
@@ -22,13 +22,14 @@
         this.a.world.strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true));
         EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a);
 
-        entityskeleton.startRiding(this.a);
+        if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit
 
         for (int i = 0; i < 3; ++i) {
             EntityHorse entityhorse = this.a(difficultydamagescaler);
+            if (entityhorse == null) continue; // CraftBukkit
             EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorse);
 
-            entityskeleton1.startRiding(entityhorse);
+            if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorse); // CraftBukkit
             entityhorse.g(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D);
         }
 
@@ -44,7 +45,7 @@
         entityhorse.setType(EnumHorseType.SKELETON);
         entityhorse.setTame(true);
         entityhorse.setAgeRaw(0);
-        entityhorse.world.addEntity(entityhorse);
+        if (!entityhorse.world.addEntity(entityhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit
         return entityhorse;
     }
 
@@ -61,7 +62,7 @@
 
         EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false);
         EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false);
-        entityskeleton.world.addEntity(entityskeleton);
+        if (!entityskeleton.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY)) return null; // CraftBukkit
         return entityskeleton;
     }
 }