Paper/Spigot-Server-Patches/0467-Optimize-Pathfinding.patch
Aikar ce270e1412
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b2f1908c SPIGOT-5783: Add helpful info to UnknownDependencyException
e4f46260 SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
529a9a69 SPIGOT-5751: Clarify behaviour of block drop-related API methods

CraftBukkit Changes:
8ea9b138 Remove outdated build delay.
ffc2b251 Revert "#675: Fix redirected CommandNodes sometimes not being properly redirected"
cb701f6b #675: Fix redirected CommandNodes sometimes not being properly redirected
c9d7c16b SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
fad2494a #673: Fix Craftworld#isChunkLoaded
8637ec00 SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given

Spigot Changes:
a99063f7 Rebuild patches

Fixes #3602
2020-06-23 04:40:03 -04:00

54 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:02:07 -0600
Subject: [PATCH] Optimize Pathfinding
Prevents pathfinding from spamming failures for things such as
arrow attacks.
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index f06764973feaa29ccbb4731b65372c544dcf3032..dc32107ec320fa54487f24c9d68ff8e5a6dea1bb 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -11,7 +11,7 @@ public abstract class NavigationAbstract {
protected final EntityInsentient a; public Entity getEntity() { return a; } // Paper - OBFHELPER
protected final World b;
@Nullable
- protected PathEntity c;
+ protected PathEntity c; protected final PathEntity getCurrentPath() { return this.c; } // Paper - OBFHELPER
protected double d;
private final AttributeInstance p;
protected int e;
@@ -158,10 +158,30 @@ public abstract class NavigationAbstract {
return this.a(this.a(d0, d1, d2, 1), d3);
}
+ // Paper start - optimise pathfinding
+ private int lastFailure = 0;
+ private int pathfindFailures = 0;
+ // Paper end
+
public boolean a(Entity entity, double d0) {
+ // Paper start - Pathfinding optimizations
+ if (this.pathfindFailures > 10 && this.getCurrentPath() == null && MinecraftServer.currentTick < this.lastFailure + 40) {
+ return false;
+ }
+ // Paper end
PathEntity pathentity = this.a(entity, 1);
- return pathentity != null && this.a(pathentity, d0);
+ // Paper start - Pathfinding optimizations
+ if (pathentity != null && this.a(pathentity, d0)) {
+ this.lastFailure = 0;
+ this.pathfindFailures = 0;
+ return true;
+ } else {
+ this.pathfindFailures++;
+ this.lastFailure = MinecraftServer.currentTick;
+ return false;
+ }
+ // Paper end
}
public boolean setDestination(@Nullable PathEntity pathentity, double speed) { return a(pathentity, speed); } // Paper - OBFHELPER