Paper/nms-patches/ItemMonsterEgg.patch
2016-12-21 07:00:00 +11:00

31 Zeilen
1.4 KiB
Diff

--- a/net/minecraft/server/ItemMonsterEgg.java
+++ b/net/minecraft/server/ItemMonsterEgg.java
@@ -152,6 +152,11 @@
@Nullable
public static Entity a(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2) {
+ return spawnCreature(world, minecraftkey, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ }
+
+ @Nullable
+ public static Entity spawnCreature(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
if (minecraftkey != null && EntityTypes.eggInfo.containsKey(minecraftkey)) {
Entity entity = null;
@@ -164,8 +169,13 @@
entityinsentient.aP = entityinsentient.yaw;
entityinsentient.aN = entityinsentient.yaw;
entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), (GroupDataEntity) null);
- world.addEntity(entity);
- entityinsentient.D();
+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled
+ if (!world.addEntity(entity, spawnReason)) {
+ entity = null;
+ } else {
+ entityinsentient.D();
+ }
+ // CraftBukkit end
}
}