summaryrefslogtreecommitdiffstats
path: root/nms-patches/MobSpawnerAbstract.patch
blob: 360ff2d3f672343cd7d093b0215d2735975e0b7d (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- ../work/decompile-8eb82bde//net/minecraft/server/MobSpawnerAbstract.java	2015-01-18 01:59:59.240758959 -0600
+++ src/main/java/net/minecraft/server/MobSpawnerAbstract.java	2015-01-18 01:59:59.244758959 -0600
@@ -4,6 +4,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.bukkit.event.entity.CreatureSpawnEvent; // CraftBukkit
+
 public abstract class MobSpawnerAbstract {
 
     public int spawnDelay = 20;
@@ -24,6 +26,11 @@
 
     public String getMobName() {
         if (this.i() == null) {
+            // CraftBukkit start - fix NPE
+            if (this.mobName == null) {
+                this.mobName = "Pig";
+            }
+            // CraftBukkit end
             if (this.mobName.equals("Minecart")) {
                 this.mobName = "MinecartRideable";
             }
@@ -129,7 +136,7 @@
 
             entity.f(nbttagcompound);
             if (entity.world != null && flag) {
-                entity.world.addEntity(entity);
+                entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
             }
 
             NBTTagCompound nbttagcompound1;
@@ -154,7 +161,7 @@
                     entity2.f(nbttagcompound2);
                     entity2.setPositionRotation(entity1.locX, entity1.locY, entity1.locZ, entity1.yaw, entity1.pitch);
                     if (entity.world != null && flag) {
-                        entity.world.addEntity(entity2);
+                        entity.world.addEntity(entity2, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
                     }
 
                     entity1.mount(entity2);
@@ -162,9 +169,9 @@
 
                 entity1 = entity2;
             }
-        } else if (entity instanceof EntityLiving && entity.world != null && flag) {
+        } else if (entity instanceof EntityInsentient && entity.world != null && flag) { // CraftBukkit - EntityLiving -> EntityInsentient
             ((EntityInsentient) entity).prepare(entity.world.E(new BlockPosition(entity)), (GroupDataEntity) null);
-            entity.world.addEntity(entity);
+            entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
         }
 
         return entity;