aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0087-Optimize-Pathfinding.patch
diff options
context:
space:
mode:
authorAikar <[email protected]>2016-02-13 19:25:23 -0600
committerZach Brown <[email protected]>2016-02-13 19:41:55 -0600
commite1db75896c596b1e23e5b4b9c54235c49028809a (patch)
tree6a73c4190d720e87a1a65cbbafb2daa74e31c37c /Spigot-Server-Patches/0087-Optimize-Pathfinding.patch
parent505386c5cbfb1c81903429fbe678d1930995250b (diff)
downloadPaper-e1db75896c596b1e23e5b4b9c54235c49028809a.tar.gz
Paper-e1db75896c596b1e23e5b4b9c54235c49028809a.zip
Optimize Pathfinding
Diffstat (limited to 'Spigot-Server-Patches/0087-Optimize-Pathfinding.patch')
-rw-r--r--Spigot-Server-Patches/0087-Optimize-Pathfinding.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0087-Optimize-Pathfinding.patch b/Spigot-Server-Patches/0087-Optimize-Pathfinding.patch
new file mode 100644
index 0000000000..4e7420c0bc
--- /dev/null
+++ b/Spigot-Server-Patches/0087-Optimize-Pathfinding.patch
@@ -0,0 +1,68 @@
+From c6cd94e6eaec67e31528ad1c871a473e9415bc61 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Mon, 18 Jan 2016 00:18:43 -0500
+Subject: [PATCH] Optimize Pathfinding
+
+Prevents pathfinding from spamming failures for things such as
+arrow attacks.
+
+Also remove a duplicate .getType() call and fix .getType() on others
+to make them use the chunk cache vs chunk lookups
+
+diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
+index d5eaa24..8ebe584 100644
+--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
++++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
+@@ -82,10 +82,25 @@ public abstract class NavigationAbstract {
+ }
+
+ public boolean a(Entity entity, double d0) {
++ // PaperSpigot start - Pathfinding optimizations
++ if (this.pathfindFailures > 10 && this.d == null && MinecraftServer.currentTick < this.lastFailure + 40) {
++ return false;
++ }
+ PathEntity pathentity = this.a(entity);
+
+- return pathentity != null ? this.a(pathentity, d0) : false;
++ if (pathentity != null && this.a(pathentity, d0)) {
++ this.lastFailure = 0;
++ this.pathfindFailures = 0;
++ return true;
++ } else {
++ this.pathfindFailures++;
++ this.lastFailure = MinecraftServer.currentTick;
++ return false;
++ }
+ }
++ private int lastFailure = 0;
++ private int pathfindFailures = 0;
++ // PaperSpigot end
+
+ public boolean a(PathEntity pathentity, double d0) {
+ if (pathentity == null) {
+@@ -205,6 +220,7 @@ public abstract class NavigationAbstract {
+ }
+
+ public void n() {
++ this.pathfindFailures = 0; this.lastFailure = 0; // PaperSpigot - Pathfinding optimizations
+ this.d = null;
+ }
+
+diff --git a/src/main/java/net/minecraft/server/PathfinderNormal.java b/src/main/java/net/minecraft/server/PathfinderNormal.java
+index 0a14c9d..629aa16 100644
+--- a/src/main/java/net/minecraft/server/PathfinderNormal.java
++++ b/src/main/java/net/minecraft/server/PathfinderNormal.java
+@@ -158,8 +158,8 @@ public class PathfinderNormal extends PathfinderAbstract {
+ flag3 = true;
+ }
+
+- if (entity.world.getType(blockposition_mutableblockposition).getBlock() instanceof BlockMinecartTrackAbstract) {
+- if (!(entity.world.getType(blockposition).getBlock() instanceof BlockMinecartTrackAbstract) && !(entity.world.getType(blockposition.down()).getBlock() instanceof BlockMinecartTrackAbstract)) {
++ if (block instanceof BlockMinecartTrackAbstract) { // PaperSpigot - Pathfinder optimizations
++ if (!(iblockaccess.getType(blockposition).getBlock() instanceof BlockMinecartTrackAbstract) && !(iblockaccess.getType(blockposition.down()).getBlock() instanceof BlockMinecartTrackAbstract)) { // PaperSpigot - Pathfinder optimizations
+ return -3;
+ }
+ } else if (!block.b(iblockaccess, blockposition_mutableblockposition) && (!flag1 || !(block instanceof BlockDoor) || block.getMaterial() != Material.WOOD)) {
+--
+2.7.1
+