73 lines
3.5 KiB
Diff
73 lines
3.5 KiB
Diff
From edc76140531322c57055473b2a2050462640a7d9 Mon Sep 17 00:00:00 2001
|
|
From: Sotr <i@omc.hk>
|
|
Date: Wed, 15 Apr 2020 17:49:07 +0700
|
|
Subject: [PATCH] Remove stream and simplify operation in pathfinder
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PathDestination.java b/src/main/java/net/minecraft/server/PathDestination.java
|
|
index 9071d43d8b..2f33aafe34 100644
|
|
--- a/src/main/java/net/minecraft/server/PathDestination.java
|
|
+++ b/src/main/java/net/minecraft/server/PathDestination.java
|
|
@@ -5,6 +5,7 @@ public class PathDestination extends PathPoint {
|
|
private float m = Float.MAX_VALUE;
|
|
private PathPoint n;
|
|
private boolean o;
|
|
+ protected BlockPosition position; // Akarin - add BlockPosition
|
|
|
|
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
|
|
--- 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 {
|
|
this.a.a();
|
|
this.e.a(chunkcache, entityinsentient);
|
|
PathPoint pathpoint = this.e.b();
|
|
+ // Akarin start - remove stream, add BlockPosition
|
|
+ /*
|
|
Map<PathDestination, BlockPosition> map = (Map) set.stream().collect(Collectors.toMap((blockposition) -> {
|
|
- return this.e.a((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
|
+ return this.e.a((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
|
}, Function.identity()));
|
|
+ */
|
|
+ Set<PathDestination> map = new java.util.HashSet<PathDestination>(set.size());
|
|
+ for (BlockPosition position : set) {
|
|
+ PathDestination dest = this.e.a((double) position.getX(), position.getY(), position.getZ());
|
|
+ dest.position = position;
|
|
+
|
|
+ map.add(dest);
|
|
+ }
|
|
+ // Akarin end
|
|
PathEntity pathentity = this.a(pathpoint, map, f, i, f1);
|
|
|
|
this.e.a();
|
|
@@ -41,8 +52,8 @@ public class Pathfinder {
|
|
}
|
|
|
|
@Nullable
|
|
- private PathEntity a(PathPoint pathpoint, Map<PathDestination, BlockPosition> map, float f, int i, float f1) {
|
|
- Set<PathDestination> set = map.keySet();
|
|
+ private PathEntity a(PathPoint pathpoint, Set<PathDestination> map, float f, int i, float f1) { // Akarin - Map -> Set
|
|
+ Set<PathDestination> set = map; // Akarin - Map -> Set
|
|
|
|
pathpoint.e = 0.0F;
|
|
pathpoint.f = this.a(pathpoint, set);
|
|
@@ -98,11 +109,11 @@ public class Pathfinder {
|
|
|
|
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
|
|
}).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
|
|
}).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e));
|
|
}
|
|
|
|
--
|
|
2.25.1.windows.1
|
|
|