From b5184575e626f22f33da722d4e266f96ce4ef38c Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Mon, 26 Nov 2018 13:23:49 +0000 Subject: [PATCH] limit the range at which we'll consider an attackable target This patch aims to ensure that MCP World#getNearestAttackablePlayer will not trigger chunk loads due to PathfinderGoalNearestAttackableTarget performing a ray trace operation by pre-checking the maximum limit; Given that the implementation shows that the limit should only ever decrease when set, allowing us to skip further checks earlier on when looking for an attackable entity --- ...ent-to-allow-plugins-to-handle-clien.patch | 4 +-- .../0033-Arrow-pickup-rule-API.patch | 4 +-- ...at-which-we-ll-consider-an-attackabl.patch | 35 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Spigot-Server-Patches/0413-limit-the-range-at-which-we-ll-consider-an-attackabl.patch diff --git a/Spigot-API-Patches/0032-Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/Spigot-API-Patches/0032-Add-handshake-event-to-allow-plugins-to-handle-clien.patch index d9c2c29f9..9f032fd05 100644 --- a/Spigot-API-Patches/0032-Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/Spigot-API-Patches/0032-Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -1,4 +1,4 @@ -From 4e0abf8c461a8e517fa30a281d90f8c60bd5686a Mon Sep 17 00:00:00 2001 +From ee3ad1b0cf85252211cdb2811557bfb7da695370 Mon Sep 17 00:00:00 2001 From: kashike Date: Wed, 13 Apr 2016 20:20:18 -0700 Subject: [PATCH] Add handshake event to allow plugins to handle client @@ -223,5 +223,5 @@ index 00000000..e44d03a2 + } +} -- -2.18.0 +2.19.1 diff --git a/Spigot-API-Patches/0033-Arrow-pickup-rule-API.patch b/Spigot-API-Patches/0033-Arrow-pickup-rule-API.patch index 905c0a477..3056f2b0b 100644 --- a/Spigot-API-Patches/0033-Arrow-pickup-rule-API.patch +++ b/Spigot-API-Patches/0033-Arrow-pickup-rule-API.patch @@ -1,4 +1,4 @@ -From 57f8f2e8bfc9419a07a28ad20fb52c13ee3e5562 Mon Sep 17 00:00:00 2001 +From 5639eb8d022329ed99bb9f92f8dbe416d5e4f377 Mon Sep 17 00:00:00 2001 From: Jedediah Smith Date: Fri, 4 Mar 2016 03:13:18 -0500 Subject: [PATCH] Arrow pickup rule API @@ -48,5 +48,5 @@ index 99814eee..34dde443 100644 + // Paper end } -- -2.18.0 +2.19.1 diff --git a/Spigot-Server-Patches/0413-limit-the-range-at-which-we-ll-consider-an-attackabl.patch b/Spigot-Server-Patches/0413-limit-the-range-at-which-we-ll-consider-an-attackabl.patch new file mode 100644 index 000000000..c941ac756 --- /dev/null +++ b/Spigot-Server-Patches/0413-limit-the-range-at-which-we-ll-consider-an-attackabl.patch @@ -0,0 +1,35 @@ +From 9615b6f9aa28294eb6338baf0d29e2e5fc1921bb Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Tue, 13 Nov 2018 14:01:00 +0000 +Subject: [PATCH] limit the range at which we'll consider an attackable target + +This patch aims to ensure that MCP World#getNearestAttackablePlayer +will not trigger chunk loads due to PathfinderGoalNearestAttackableTarget +performing a ray trace operation by pre-checking the maximum limit; + +Given that the implementation shows that the limit should only ever +decrease when set, allowing us to skip further checks earlier on +when looking for an attackable entity + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index cdbb247da..027871c00 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -2795,8 +2795,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + for (int i = 0; i < this.players.size(); ++i) { + EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); + ++ // Paper start ++ // move distance check up, if set, check distance^2 is less than XZlimit^2, continue ++ // 4th method param is XZlimit (at least at the time of commit) ++ double d6 = entityhuman1.d(d0, entityhuman1.locY, d2); ++ if (d3 < 0.0D || d6 < d3 * d3) + if (!entityhuman1.abilities.isInvulnerable && entityhuman1.isAlive() && !entityhuman1.isSpectator() && (predicate == null || predicate.test(entityhuman1))) { +- double d6 = entityhuman1.d(d0, entityhuman1.locY, d2); ++ // Paper end + double d7 = d3; + + if (entityhuman1.isSneaking()) { +-- +2.19.1 +