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

@@ -72,7 +72,7 @@
a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> {
return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess);
}, (entityinsentient, ichunkaccess) -> {
@@ -147,10 +191,13 @@
@@ -147,10 +191,14 @@
entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F);
if (a(worldserver, entityinsentient, d2)) {
groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
@@ -81,7 +81,8 @@
- worldserver.addAllEntities(entityinsentient);
- spawnercreature_a.run(entityinsentient, ichunkaccess);
+ // CraftBukkit start
+ if (worldserver.addAllEntities(entityinsentient, SpawnReason.NATURAL)) {
+ worldserver.addAllEntities(entityinsentient, SpawnReason.NATURAL);
+ if (!entityinsentient.dead) {
+ ++j;
+ ++k1;
+ spawnercreature_a.run(entityinsentient, ichunkaccess);
@@ -90,7 +91,7 @@
if (j >= entityinsentient.getMaxSpawnGroup()) {
return;
}
@@ -333,7 +380,7 @@
@@ -333,7 +381,7 @@
if (entityinsentient.a((GeneratorAccess) worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) worldaccess)) {
groupdataentity = entityinsentient.prepare(worldaccess, worldaccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null);
@@ -99,7 +100,7 @@
flag = true;
}
}
@@ -456,8 +503,10 @@
@@ -456,8 +504,10 @@
return this.d;
}