From 1e60258bfd81c497479f2cc2d53b8db594b1d3fb Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 27 Apr 2019 10:07:55 +1000 Subject: [PATCH] SPIGOT-4783: CreatureSpawnEvent causes crash when getting block type By: md_5 --- paper-server/nms-patches/PlayerChunkMap.patch | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/paper-server/nms-patches/PlayerChunkMap.patch b/paper-server/nms-patches/PlayerChunkMap.patch index 1a309c3d19..e9eeb035c9 100644 --- a/paper-server/nms-patches/PlayerChunkMap.patch +++ b/paper-server/nms-patches/PlayerChunkMap.patch @@ -81,19 +81,7 @@ }); } } -@@ -454,7 +471,10 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - -- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { -+ // CraftBukkit start -+ boolean addEntity = !chunk.needsDecoration || CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // Only call for new chunks -+ if (addEntity && !(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { -+ // CraftBukkit end - if (list == null) { - list = Lists.newArrayList(new Entity[] { entity}); - } else { -@@ -476,7 +496,7 @@ +@@ -476,7 +493,7 @@ long i = playerchunk.h().pair(); playerchunk.getClass(); @@ -102,7 +90,7 @@ }); } -@@ -493,7 +513,7 @@ +@@ -493,7 +510,7 @@ return Either.left(chunk); }); }, (runnable) -> { @@ -111,7 +99,7 @@ }); completablefuture1.thenAcceptAsync((either) -> { -@@ -507,7 +527,7 @@ +@@ -507,7 +524,7 @@ return Either.left(chunk); }); }, (runnable) -> { @@ -120,7 +108,7 @@ }); return completablefuture1; } -@@ -517,8 +537,14 @@ +@@ -517,8 +534,14 @@ } public void saveChunk(IChunkAccess ichunkaccess) { @@ -136,7 +124,7 @@ try { this.world.checkSession(); } catch (ExceptionWorldConflict exceptionworldconflict) { -@@ -569,9 +595,10 @@ +@@ -569,9 +592,10 @@ ChunkCoordIntPair chunkcoordintpair = playerchunk.h(); Packet[] apacket = new Packet[2]; @@ -148,7 +136,7 @@ boolean flag1 = i1 <= this.A; this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1); -@@ -626,7 +653,7 @@ +@@ -626,7 +650,7 @@ private NBTTagCompound f(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); @@ -157,7 +145,7 @@ } boolean d(ChunkCoordIntPair chunkcoordintpair) { -@@ -946,7 +973,7 @@ +@@ -946,7 +970,7 @@ public final Set trackedPlayers = Sets.newHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -166,7 +154,7 @@ this.tracker = entity; this.trackingDistance = i; this.e = SectionPosition.a(entity); -@@ -1015,6 +1042,17 @@ +@@ -1015,6 +1039,17 @@ } }