SPIGOT-6186: Canceling a CreatureSpawnEvent​ results in a "Unable to summon entity due to duplicate UUIDs" error

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2020-11-17 13:41:47 +11:00
parent 889488ff73
commit 658c0a284a
4 changed files with 30 additions and 30 deletions

View File

@@ -18,7 +18,7 @@
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
}
@@ -169,10 +169,17 @@
@@ -169,10 +169,18 @@
@Nullable
public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
@@ -32,12 +32,13 @@
if (t0 != null) {
- worldserver.addAllEntities(t0);
+ return worldserver.addAllEntities(t0, spawnReason) ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
+ worldserver.addAllEntities(t0, spawnReason);
+ return !t0.dead ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
+ // CraftBukkit end
}
return t0;
@@ -208,7 +215,7 @@
@@ -208,7 +216,7 @@
t0.setCustomName(ichatbasecomponent);
}
@@ -46,7 +47,7 @@
return t0;
}
}
@@ -351,7 +358,7 @@
@@ -351,7 +359,7 @@
}
return entity;
@@ -55,7 +56,7 @@
}
private static Optional<Entity> b(NBTTagCompound nbttagcompound, World world) {
@@ -403,7 +410,7 @@
@@ -403,7 +411,7 @@
this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
}