From 70cc3820cfe2b7e97b0096e50b6d6057857cb7cc Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Dec 2017 17:32:19 +1100 Subject: SPIGOT-3686: Move entity event call earlier in method --- nms-patches/World.patch | 67 +++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 38 deletions(-) (limited to 'nms-patches/World.patch') diff --git a/nms-patches/World.patch b/nms-patches/World.patch index 1c43e866..e4f6e071 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -259,7 +259,7 @@ if (this.E(blockposition)) { return Blocks.AIR.getBlockData(); } else { -@@ -788,6 +966,13 @@ +@@ -788,6 +966,42 @@ } public boolean addEntity(Entity entity) { @@ -269,15 +269,7 @@ + + public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason + if (entity == null) return false; -+ // CraftBukkit end - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - boolean flag = entity.attachedToPlayer; -@@ -796,6 +981,37 @@ - flag = true; - } - -+ // CraftBukkit start ++ + org.bukkit.event.Cancellable event = null; + if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { + boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem; @@ -307,11 +299,10 @@ + } + // CraftBukkit end + -+ - if (!flag && !this.isChunkLoaded(i, j, false)) { - return false; - } else { -@@ -818,6 +1034,7 @@ + int i = MathHelper.floor(entity.locX / 16.0D); + int j = MathHelper.floor(entity.locZ / 16.0D); + boolean flag = entity.attachedToPlayer; +@@ -818,6 +1032,7 @@ ((IWorldAccess) this.u.get(i)).a(entity); } @@ -319,7 +310,7 @@ } protected void c(Entity entity) { -@@ -825,6 +1042,7 @@ +@@ -825,6 +1040,7 @@ ((IWorldAccess) this.u.get(i)).b(entity); } @@ -327,7 +318,7 @@ } public void kill(Entity entity) { -@@ -860,7 +1078,15 @@ +@@ -860,7 +1076,15 @@ this.getChunkAt(i, j).b(entity); } @@ -344,7 +335,7 @@ this.c(entity); } -@@ -977,7 +1203,7 @@ +@@ -977,7 +1201,7 @@ } public boolean a(AxisAlignedBB axisalignedbb) { @@ -353,7 +344,7 @@ } public int a(float f) { -@@ -1047,6 +1273,11 @@ +@@ -1047,6 +1271,11 @@ for (i = 0; i < this.j.size(); ++i) { entity = (Entity) this.j.get(i); @@ -365,7 +356,7 @@ try { ++entity.ticksLived; -@@ -1095,8 +1326,10 @@ +@@ -1095,8 +1324,10 @@ CrashReportSystemDetails crashreportsystemdetails1; CrashReport crashreport1; @@ -378,7 +369,7 @@ Entity entity1 = entity.bJ(); if (entity1 != null) { -@@ -1129,7 +1362,7 @@ +@@ -1129,7 +1360,7 @@ this.getChunkAt(j, l).b(entity); } @@ -387,7 +378,7 @@ this.c(entity); } -@@ -1184,9 +1417,11 @@ +@@ -1184,9 +1415,11 @@ TileEntity tileentity1 = (TileEntity) this.b.get(i1); if (!tileentity1.y()) { @@ -399,7 +390,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -1194,6 +1429,12 @@ +@@ -1194,6 +1427,12 @@ chunk.a(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -412,7 +403,7 @@ } } } -@@ -1247,15 +1488,13 @@ +@@ -1247,15 +1486,13 @@ int i; int j; @@ -434,7 +425,7 @@ entity.M = entity.locX; entity.N = entity.locY; -@@ -1268,6 +1507,7 @@ +@@ -1268,6 +1505,7 @@ entity.aE(); } else { entity.B_(); @@ -442,7 +433,7 @@ } } -@@ -1559,11 +1799,18 @@ +@@ -1559,11 +1797,18 @@ } } @@ -461,7 +452,7 @@ TileEntity tileentity = null; if (this.O) { -@@ -1598,6 +1845,14 @@ +@@ -1598,6 +1843,14 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!this.E(blockposition)) { if (tileentity != null && !tileentity.y()) { @@ -476,7 +467,7 @@ if (this.O) { tileentity.setPosition(blockposition); Iterator iterator = this.b.iterator(); -@@ -1757,6 +2012,14 @@ +@@ -1757,6 +2010,14 @@ } this.o = MathHelper.a(this.o, 0.0F, 1.0F); @@ -491,7 +482,7 @@ } } } -@@ -1894,7 +2157,10 @@ +@@ -1894,7 +2155,10 @@ } public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { @@ -503,7 +494,7 @@ return false; } else { int i = 0; -@@ -2061,7 +2327,7 @@ +@@ -2061,7 +2325,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -512,7 +503,7 @@ arraylist.add(entity); } } -@@ -2076,7 +2342,7 @@ +@@ -2076,7 +2340,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -521,7 +512,7 @@ arraylist.add(entity); } } -@@ -2125,7 +2391,7 @@ +@@ -2125,7 +2389,7 @@ } } @@ -530,7 +521,7 @@ } @Nullable -@@ -2146,8 +2412,17 @@ +@@ -2146,8 +2410,17 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -549,7 +540,7 @@ ++i; } } -@@ -2156,12 +2431,18 @@ +@@ -2156,12 +2429,18 @@ } public void a(Collection collection) { @@ -569,7 +560,7 @@ this.b(entity); } -@@ -2175,7 +2456,13 @@ +@@ -2175,7 +2454,13 @@ IBlockData iblockdata = this.getType(blockposition); AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition); @@ -584,7 +575,7 @@ } public int getSeaLevel() { -@@ -2285,6 +2572,11 @@ +@@ -2285,6 +2570,11 @@ for (int i = 0; i < this.players.size(); ++i) { EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); @@ -596,7 +587,7 @@ if (predicate.apply(entityhuman1)) { double d5 = entityhuman1.d(d0, d1, d2); -@@ -2453,6 +2745,16 @@ +@@ -2453,6 +2743,16 @@ public void everyoneSleeping() {} @@ -613,7 +604,7 @@ public float h(float f) { return (this.p + (this.q - this.p) * f) * this.j(f); } -@@ -2670,7 +2972,7 @@ +@@ -2670,7 +2970,7 @@ int l = j * 16 + 8 - blockposition.getZ(); boolean flag = true; -- cgit v1.2.3