Don't decrement ItemStack when CreatureSpawnEvent is canceled - addresses SPIGOT-87

This commit is contained in:
DemonWav 2014-12-13 23:59:49 -06:00 committed by Thinkofdeath
parent 28f37a113c
commit 55e592e542

View file

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//net/minecraft/server/ItemMonsterEgg.java 2014-12-03 10:52:09.804159084 +0000
+++ src/main/java/net/minecraft/server/ItemMonsterEgg.java 2014-12-03 10:51:53.380159449 +0000
--- ../work/decompile-8eb82bde/net/minecraft/server/ItemMonsterEgg.java 2014-12-15 13:53:30.086979118 +0000
+++ src/main/java/net/minecraft/server/ItemMonsterEgg.java 2014-12-15 13:53:30.086979118 +0000
@@ -19,7 +19,8 @@
}
@ -23,12 +23,19 @@
if (!EntityTypes.eggInfo.containsKey(Integer.valueOf(i))) {
return null;
} else {
@@ -123,7 +130,7 @@
@@ -123,8 +130,13 @@
entityinsentient.aI = entityinsentient.yaw;
entityinsentient.aG = entityinsentient.yaw;
entityinsentient.prepare(world.E(new BlockPosition(entityinsentient)), (GroupDataEntity) null);
- world.addEntity(entity);
+ world.addEntity(entity, spawnReason); // CraftBukkit
entityinsentient.x();
- entityinsentient.x();
+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled
+ if (!world.addEntity(entity, spawnReason)) {
+ entity = null;
+ } else {
+ entityinsentient.x();
+ }
+ // CraftBukkit end
}
}