diff --git a/patches/server/0021-Remove-stream-and-simplify-operation-in-pathfinder.patch b/patches/server/0021-Remove-stream-and-simplify-operation-in-pathfinder.patch index 9cbfb51bf..e02356021 100644 --- a/patches/server/0021-Remove-stream-and-simplify-operation-in-pathfinder.patch +++ b/patches/server/0021-Remove-stream-and-simplify-operation-in-pathfinder.patch @@ -1,4 +1,4 @@ -From 973aed2e4aaa03aa708a697a9d0339f01f5f0e98 Mon Sep 17 00:00:00 2001 +From 7b07c24aa3a90facbd8a0a31ed414d9ea442a32b Mon Sep 17 00:00:00 2001 From: Sotr Date: Wed, 15 Apr 2020 17:49:07 +0700 Subject: [PATCH] Remove stream and simplify operation in pathfinder @@ -17,10 +17,20 @@ index 9071d43d8b..2f33aafe34 100644 public PathDestination(PathPoint pathpoint) { super(pathpoint.a, pathpoint.b, pathpoint.c); diff --git a/src/main/java/net/minecraft/server/Pathfinder.java b/src/main/java/net/minecraft/server/Pathfinder.java -index 848e2fe8b8..6eb4d13f8b 100644 +index 848e2fe8b8..379ee96b08 100644 --- a/src/main/java/net/minecraft/server/Pathfinder.java +++ b/src/main/java/net/minecraft/server/Pathfinder.java -@@ -31,9 +31,20 @@ public class Pathfinder { +@@ -2,7 +2,9 @@ package net.minecraft.server; + + import com.google.common.collect.Lists; + import com.google.common.collect.Sets; ++import java.util.Collections; + import java.util.Comparator; ++import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; +@@ -31,9 +33,20 @@ public class Pathfinder { this.a.a(); this.e.a(chunkcache, entityinsentient); PathPoint pathpoint = this.e.b(); @@ -31,7 +41,7 @@ index 848e2fe8b8..6eb4d13f8b 100644 + return this.e.a((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); }, Function.identity())); + */ -+ Set map = new java.util.HashSet(set.size()); ++ List map = new java.util.ArrayList(set.size()); + for (BlockPosition position : set) { + PathDestination dest = this.e.a((double) position.getX(), position.getY(), position.getZ()); + dest.position = position; @@ -42,31 +52,103 @@ index 848e2fe8b8..6eb4d13f8b 100644 PathEntity pathentity = this.a(pathpoint, map, f, i, f1); this.e.a(); -@@ -41,8 +52,8 @@ public class Pathfinder { +@@ -41,8 +54,8 @@ public class Pathfinder { } @Nullable - private PathEntity a(PathPoint pathpoint, Map map, float f, int i, float f1) { - Set set = map.keySet(); -+ private PathEntity a(PathPoint pathpoint, Set map, float f, int i, float f1) { // Akarin - Map -> Set -+ Set set = map; // Akarin - Map -> Set ++ private PathEntity a(PathPoint pathpoint, List map, float f, int i, float f1) { // Akarin - Map -> List ++ List set = map; // Akarin - Map -> List pathpoint.e = 0.0F; pathpoint.f = this.a(pathpoint, set); -@@ -98,11 +109,11 @@ public class Pathfinder { +@@ -53,6 +66,7 @@ public class Pathfinder { + int j = 0; + int k = (int) ((float) this.d * f1); + ++ List destinations = new java.util.ArrayList(); // Akarin - remove stream + while (!this.a.e()) { + ++j; + if (j >= k) { +@@ -62,12 +76,26 @@ public class Pathfinder { + PathPoint pathpoint1 = this.a.c(); + + pathpoint1.i = true; ++ // Akarin start - remove stream ++ /* + set.stream().filter((pathdestination) -> { + return pathpoint1.c((PathPoint) pathdestination) <= (float) i; + }).forEach(PathDestination::e); + if (set.stream().anyMatch(PathDestination::f)) { + break; + } ++ */ ++ for (PathDestination dest : set) { ++ if (pathpoint1.c((PathPoint) dest) <= (float) i) ++ dest.e(); ++ ++ if (dest.f()) ++ destinations.add(createPathEntityBy(dest.d(), dest.position, true)); // copied from below ++ } ++ ++ if (!destinations.isEmpty()) ++ break; ++ // Akarin end + + if (pathpoint1.a(pathpoint) < f) { + int l = this.e.a(this.c, pathpoint1); +@@ -94,15 +122,17 @@ public class Pathfinder { + } + } + ++ // Akarin start - remove stream ++ /* + Stream stream; if (set.stream().anyMatch(PathDestination::f)) { stream = set.stream().filter(PathDestination::f).map((pathdestination) -> { - return this.a(pathdestination.d(), (BlockPosition) map.get(pathdestination), true); -+ return this.a(pathdestination.d(), (BlockPosition) pathdestination.position, true); // Akarin - add BlockPosition ++ return this.a(pathdestination.d(), (BlockPosition) pathdestination.position, true); }).sorted(Comparator.comparingInt(PathEntity::e)); } else { stream = set.stream().map((pathdestination) -> { - return this.a(pathdestination.d(), (BlockPosition) map.get(pathdestination), false); -+ return this.a(pathdestination.d(), (BlockPosition) pathdestination.position, false); // Akarin - add BlockPosition ++ return this.a(pathdestination.d(), (BlockPosition) pathdestination.position, false); }).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e)); } +@@ -115,9 +145,21 @@ public class Pathfinder { + + return pathentity; + } ++ */ ++ if (!destinations.isEmpty()) { ++ Collections.sort(destinations, Comparator.comparingInt(PathEntity::e)); ++ } else { ++ for (PathDestination dest : set) ++ destinations.add(createPathEntityBy(dest.d(), dest.position, false)); ++ ++ Collections.sort(destinations, Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e)); ++ } ++ ++ return destinations.get(0); ++ // Akarin end + } + +- private float a(PathPoint pathpoint, Set set) { ++ private float a(PathPoint pathpoint, List set) { // Akarin - Set -> List + float f = Float.MAX_VALUE; + + float f1; +@@ -132,6 +174,7 @@ public class Pathfinder { + return f; + } + ++ private PathEntity createPathEntityBy(PathPoint pathpoint, BlockPosition blockposition, boolean flag) { return this.a(pathpoint, blockposition, flag); } // Akarin - OBFHELPER + private PathEntity a(PathPoint pathpoint, BlockPosition blockposition, boolean flag) { + List list = Lists.newArrayList(); + PathPoint pathpoint1 = pathpoint; -- 2.25.1.windows.1 diff --git a/patches/server/0022-Remove-a-few-more-streams.patch b/patches/server/0022-Remove-a-few-more-streams.patch index ef006e723..5bb5aa062 100644 --- a/patches/server/0022-Remove-a-few-more-streams.patch +++ b/patches/server/0022-Remove-a-few-more-streams.patch @@ -1,4 +1,4 @@ -From 0793ce59f94297b12c49511ebe65c6f7914ea681 Mon Sep 17 00:00:00 2001 +From c9cdd49decdb2cf080feaef08f76a0dbbd2d72bf Mon Sep 17 00:00:00 2001 From: Sotr Date: Wed, 15 Apr 2020 22:45:48 +0700 Subject: [PATCH] Remove a few more streams