summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityTypes.patch
blob: 25a77d3406d24afeea834fd804873a330ccfd86c (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
--- a/net/minecraft/server/EntityTypes.java
+++ b/net/minecraft/server/EntityTypes.java
@@ -121,7 +121,7 @@
     public static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.a<T> entitytypes_a) {
         EntityTypes entitytypes = entitytypes_a.a(s);
 
-        IRegistry.ENTITY_TYPE.a(new MinecraftKey(s), (Object) entitytypes);
+        IRegistry.ENTITY_TYPE.a(new MinecraftKey(s), entitytypes); // CraftBukkit - decompile error
         return entitytypes;
     }
 
@@ -150,10 +150,16 @@
 
     @Nullable
     public T a(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1) {
+        // CraftBukkit start
+        return spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+    }
+
+    @Nullable
+    public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
         Entity entity = this.b(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1);
 
-        world.addEntity(entity);
-        return entity;
+        return world.addEntity(entity, spawnReason) ? (T) entity : null; // Don't return an entity when CreatureSpawnEvent is canceled
+        // CraftBukkit end
     }
 
     @Nullable
@@ -187,7 +193,7 @@
             }
 
             a(world, entityhuman, entity, nbttagcompound);
-            return entity;
+            return (T) entity; // CraftBukkit - decompile error
         }
     }
 
@@ -250,7 +256,7 @@
 
     @Nullable
     public T a(World world) {
-        return (Entity) this.aT.apply(world);
+        return this.aT.apply(world); // CraftBukkit - decompile error
     }
 
     @Nullable