2019-03-16 03:25:32 +00:00
|
|
|
From 8b6f31ea522b02770ab4dfd2719b3827b605a8cd Mon Sep 17 00:00:00 2001
|
2018-11-26 13:23:49 +00:00
|
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
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
|
2019-03-16 03:25:32 +00:00
|
|
|
index 2f12e35a..a7f6288f 100644
|
2018-11-26 13:23:49 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-02-03 15:34:04 +00:00
|
|
|
@@ -2729,8 +2729,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-11-26 13:23:49 +00:00
|
|
|
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()) {
|
|
|
|
--
|
2019-03-16 03:25:32 +00:00
|
|
|
2.20.1
|
2018-11-26 13:23:49 +00:00
|
|
|
|