mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add Paper's dropped optimize pathfinder patch
This commit is contained in:
59
patches/server/0109-Optimize-Pathfinding.patch
Normal file
59
patches/server/0109-Optimize-Pathfinding.patch
Normal file
@@ -0,0 +1,59 @@
|
||||
From e4c0dca628bd0a486acff7b5f2a396c0ee59510c 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.
|
||||
---
|
||||
.../minecraft/server/NavigationAbstract.java | 24 +++++++++++++++++--
|
||||
1 file changed, 22 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
||||
index f06764973..ac29f8937 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; } // Purpur - 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);
|
||||
}
|
||||
|
||||
+ // Purpur start - optimise pathfinding
|
||||
+ private int lastFailure = 0;
|
||||
+ private int pathfindFailures = 0;
|
||||
+ // Purpur end
|
||||
+
|
||||
public boolean a(Entity entity, double d0) {
|
||||
+ // Purpur start - Pathfinding optimizations
|
||||
+ if (this.pathfindFailures > 10 && this.getCurrentPath() == null && MinecraftServer.currentTick < this.lastFailure + 40) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
PathEntity pathentity = this.a(entity, 1);
|
||||
|
||||
- return pathentity != null && this.a(pathentity, d0);
|
||||
+ // Purpur 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;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
public boolean setDestination(@Nullable PathEntity pathentity, double speed) { return a(pathentity, speed); } // Paper - OBFHELPER
|
||||
--
|
||||
2.24.0
|
||||
|
||||
Reference in New Issue
Block a user