more work
This commit is contained in:
21
patches/server/0002-mc-dev-fixes.patch
Normal file
21
patches/server/0002-mc-dev-fixes.patch
Normal file
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sat, 2 Nov 2024 15:26:27 +0900
|
||||
Subject: [PATCH] mc dev fixes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/AllayAi.java b/src/main/java/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
index 3fc1ec01e1a77a169ec762a23f15b97f040ce5f8..b5464708c1fa949e7df8aed71126ccad72d66ee3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
@@ -62,8 +62,8 @@ public class AllayAi {
|
||||
Activity.CORE,
|
||||
0,
|
||||
ImmutableList.of(
|
||||
- new Swim<>(0.8F),
|
||||
- new AnimalPanic(2.5F),
|
||||
+ new Swim<Allay>(0.8F), // Plazma - mc dev fixes
|
||||
+ new AnimalPanic<Allay>(2.5F), // Plazma - mc dev fixes
|
||||
new LookAtTargetSink(45, 90),
|
||||
new MoveToTargetSink(),
|
||||
new CountDownCooldownTicks(MemoryModuleType.LIKED_NOTEBLOCK_COOLDOWN_TICKS),
|
||||
@@ -17,7 +17,7 @@ index 27eb9a365006884c85603dc6d9dd8eee009c98b3..958a48d05aba8e500c7b19a466dcca6f
|
||||
FluidState fluid = world.getFluidState(blockposition1);
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index 7bd566d6e15385850930a6c0b44d1d495a671e81..d5e7d74b0e203c9f2c03c9b4f8d1b9c57168e61f 100644
|
||||
index e50118ec7a4c00bd367ca6c740214c53b0d60fc9..4d204a0dc976d96c98764092c8461b0e2b920fc1 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -31,6 +31,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
@@ -24,7 +24,7 @@ index 61b19f52aeb371abdd29f41291099f35a9b4c258..dcb0a4461a2fca964e4d8390401e4636
|
||||
return false;
|
||||
} else if (this.player.isChangingDimension()) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 3ec9c947ac19412ad81d0cc85e0eff289a285d1e..af89ad0fcaebb5776ae3c18d02441c48f4227251 100644
|
||||
index b3fccda131e51b03b1617b028f8d7488db342f24..6fd1f1c859a6e6cea780d9dfa9a2770d59ddfd04 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -27,6 +27,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
@@ -33,7 +33,7 @@ index 3f39d6c786d9dfdd9ad591e08ff05fcbb41a1df6..0346fd4ab7095d66c0eef5a440afbc7a
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index af89ad0fcaebb5776ae3c18d02441c48f4227251..aa8b0a9b3d98e2c2fb1bd3c374cd2e742e6e17cf 100644
|
||||
index 6fd1f1c859a6e6cea780d9dfa9a2770d59ddfd04..af0ca8b0470c0e66cbc4cc0331219b71d0fa429f 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -35,6 +35,24 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
7004
patches/server/0042-Remove-persist-isClientSide-flag.patch
Normal file
7004
patches/server/0042-Remove-persist-isClientSide-flag.patch
Normal file
File diff suppressed because it is too large
Load Diff
21
patches/server/0043-minor-code-improvements.patch
Normal file
21
patches/server/0043-minor-code-improvements.patch
Normal file
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sat, 2 Nov 2024 15:10:12 +0900
|
||||
Subject: [PATCH] minor code improvements
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndGatewayBlock.java b/src/main/java/net/minecraft/world/level/block/EndGatewayBlock.java
|
||||
index e5c5e20b0f2b2094faae2955a886f06ef6771eff..f19ab0a7daa671727675c2d03b3c77b287062f75 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndGatewayBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndGatewayBlock.java
|
||||
@@ -100,8 +100,8 @@ public class EndGatewayBlock extends BaseEntityBlock implements Portal {
|
||||
// Paper end - call EntityPortalEnterEvent
|
||||
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||
|
||||
- if (/*!world.isClientSide &&*/ tileentity instanceof TheEndGatewayBlockEntity) { // Plazma - Remove persist flag
|
||||
- TheEndGatewayBlockEntity tileentityendgateway = (TheEndGatewayBlockEntity) tileentity;
|
||||
+ if (/*!world.isClientSide &&*/ tileentity instanceof TheEndGatewayBlockEntity tileentityendgateway) { // Plazma - Remove persist flag // Plazma - minor code improvements
|
||||
+ //TheEndGatewayBlockEntity tileentityendgateway = (TheEndGatewayBlockEntity) tileentity; // Plazma - minor code improvements
|
||||
|
||||
if (!tileentityendgateway.isCoolingDown()) {
|
||||
// Purpur start
|
||||
@@ -464,10 +464,10 @@ index 0000000000000000000000000000000000000000..3456f38d381643b0461669b0b5fec6bf
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
index 3d7578605..280ada75d 100644
|
||||
index 3d7578605812021bc84b99d4db1672a682d897ad..58feaaed5e301eb402dab24e6f155beb865fa5ee 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -76,6 +77,35 @@ public class AcquirePoi {
|
||||
@@ -76,6 +76,35 @@ public class AcquirePoi {
|
||||
io.papermc.paper.util.PoiAccess.findNearestPoiPositions(poiManager, poiPredicate, predicate2, entity.blockPosition(), world.purpurConfig.villagerAcquirePoiSearchRadius, world.purpurConfig.villagerAcquirePoiSearchRadius*world.purpurConfig.villagerAcquirePoiSearchRadius, PoiManager.Occupancy.HAS_SPACE, false, 5, poiposes);
|
||||
Set<Pair<Holder<PoiType>, BlockPos>> set = new java.util.HashSet<>(poiposes);
|
||||
// Paper end - optimise POI access
|
||||
@@ -736,7 +736,7 @@ index a3e0c5af4cc9323c02e88e768cbda9e46854aea1..d68e97084ba6bc97312fc5b62ffcb6e6
|
||||
if (this.canUpdatePath()) {
|
||||
this.followThePath();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
index f73b559b8..d21860444 100644
|
||||
index f73b559b8e60859020f762dab88b67b8c912bf8f..d218604447afbde96dc4af33ba90a87617a13ed4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
@@ -24,10 +24,23 @@ public class GroundPathNavigation extends PathNavigation {
|
||||
@@ -764,7 +764,7 @@ index f73b559b8..d21860444 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index a5289b6c4..a093bd380 100644
|
||||
index c7c6385c71c5bfae5818976008feececf5890654..b54c7b274c5c4eefc8c0170b89a6c7d7d02f5f08 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -168,6 +168,7 @@ public abstract class PathNavigation {
|
||||
@@ -836,7 +836,7 @@ index a5289b6c4..a093bd380 100644
|
||||
Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0, ((double)node.y + this.mob.getY()) / 2.0, ((double)node.z + this.mob.getZ()) / 2.0);
|
||||
return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex()));
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
index 0446ac540..77c10a3e9 100644
|
||||
index 0446ac540d8509a653abe1a8bc10f52fb43d6ae1..77c10a3e9570f53ce73dacb39cb86a00202e6ce6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java
|
||||
@@ -15,10 +15,23 @@ public class WaterBoundPathNavigation extends PathNavigation {
|
||||
@@ -894,7 +894,7 @@ index 9104d7010bda6f9f73b478c11490ef9c53f76da2..a53950a6e4cb2e672b6f130461fa6306
|
||||
// Paper end - optimise POI access
|
||||
if (path != null && path.canReach()) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index dc8df0912..c4a59c134 100644
|
||||
index 6c4cab8cabdd27b6dbd97a408a588f4ef9684654..32a1bb3ea64099c4583607ee246b8cadb77c4d44 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -1206,7 +1206,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@@ -916,10 +916,10 @@ index dc8df0912..c4a59c134 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 94ca73551..3ae1875be 100644
|
||||
index 62991c7d1c4d62669adeb30b56c94b0e7d998ab2..2077ccca3f6f942ec7daa06759ce0532b11a00a5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -503,10 +504,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
@@ -505,10 +505,23 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||
return nodeType != PathType.WATER_BORDER && super.canCutCorner(nodeType);
|
||||
}
|
||||
|
||||
@@ -944,7 +944,7 @@ index 94ca73551..3ae1875be 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
index 949207eda..12b3c0454 100644
|
||||
index de3d91891000c599950e31da595c254a3b421e7a..a73d7a1ea1ef7a98a114b7d10de6b2946c092f76 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java
|
||||
@@ -308,7 +308,7 @@ public class Drowned extends Zombie implements RangedAttackMob {
|
||||
@@ -952,15 +952,15 @@ index 949207eda..12b3c0454 100644
|
||||
protected boolean closeToNextPos() {
|
||||
Path path = this.getNavigation().getPath();
|
||||
- if (path != null) {
|
||||
+ if (path != null && path.isProcesssed()) { // Plazma - Process pathfinding asynchronously
|
||||
+ if (path != null && path.isProcessed()) { // Plazma - Process pathfinding asynchronously
|
||||
BlockPos blockPos = path.getTarget();
|
||||
if (blockPos != null) {
|
||||
double d = this.distanceToSqr((double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
index c3b5b34a5..6bef9da97 100644
|
||||
index d414158e1222f9a4f73a33abcf96f994aee4efde..dec0fd7d0b704c20df03b3c17fae1af921217e11 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java
|
||||
@@ -608,10 +608,23 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
||||
@@ -610,10 +610,23 @@ public class Strider extends Animal implements ItemSteerable, Saddleable {
|
||||
super(entity, world);
|
||||
}
|
||||
|
||||
@@ -985,10 +985,10 @@ index c3b5b34a5..6bef9da97 100644
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
index 9f542e4f0..d7fff7005 100644
|
||||
index bcc1f2e8ad66eb826617f17d98fb43649fc8deb2..421a255dcb9843b34e8b0e39b65ee9b1bbd3ed0d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
||||
@@ -634,6 +634,15 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
@@ -636,6 +636,15 @@ public class Warden extends Monster implements VibrationSystem {
|
||||
protected PathFinder createPathFinder(int range) {
|
||||
this.nodeEvaluator = new WalkNodeEvaluator();
|
||||
this.nodeEvaluator.setCanPassDoors(true);
|
||||
@@ -1026,60 +1026,47 @@ index d9d0fff9962131808d54cca20f209df50b8e4af1..420dd323790e72aa12c942d31a94bcb8
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeCollection(this.targetNodes, (bufx, node) -> node.writeToStream(bufx));
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a153997dc75672 100644
|
||||
index f1aa182d7cc0ffac23ddb1f77335c61ca9f6f720..bc98944d37d5eb96a58092c31d7cb108249b7701 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.util.profiling.metrics.MetricCategory;
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.core.BlockPos;
|
||||
//import net.minecraft.util.profiling.metrics.MetricCategory; // Plazma - Completely remove Mojang's Profiler
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.PathNavigationRegion;
|
||||
+import dev.kaiijumc.kaiiju.path.*; // Plazma - Process pathfinding asynchronously
|
||||
|
||||
public class PathFinder {
|
||||
private static final float FUDGING = 1.5F;
|
||||
@@ -24,91 +25,138 @@ public class PathFinder {
|
||||
@@ -25,8 +26,20 @@ public class PathFinder {
|
||||
public final NodeEvaluator nodeEvaluator;
|
||||
private static final boolean DEBUG = false;
|
||||
private final BinaryHeap openSet = new BinaryHeap();
|
||||
+ // Plazma start - Process pathfinding asynchronously
|
||||
+ public static boolean ASYNC = false;
|
||||
+ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
||||
+ private final @Nullable NodeEvaluatorGenerator evaluatorGenerator;
|
||||
+ // Plazma end - Process pathfinding asynchronously
|
||||
|
||||
public PathFinder(NodeEvaluator pathNodeMaker, int range) {
|
||||
+ // Plazma start - Process pathfinding asynchronously
|
||||
+ this(pathNodeMaker, range, null);
|
||||
+ }
|
||||
+
|
||||
+ public PathFinder(NodeEvaluator pathNodeMaker, int range, @Nullable NodeEvaluatorGenerator evaluatorGenerator) {
|
||||
+ this.evaluatorGenerator = evaluatorGenerator;
|
||||
+ // Plazma end - Process pathfinding asynchronously
|
||||
this.nodeEvaluator = pathNodeMaker;
|
||||
this.maxVisitedNodes = range;
|
||||
+ this.evaluatorGenerator = evaluatorGenerator;
|
||||
}
|
||||
@@ -37,100 +50,48 @@ public class PathFinder {
|
||||
|
||||
+ @SuppressWarnings("ConstantValue")
|
||||
@Nullable
|
||||
- public Path findPath(PathNavigationRegion world, Mob mob, Set<BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
public Path findPath(PathNavigationRegion world, Mob mob, Set<BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
- this.openSet.clear();
|
||||
- this.nodeEvaluator.prepare(world, mob);
|
||||
- Node node = this.nodeEvaluator.getStart();
|
||||
+ public Path findPath(
|
||||
+ PathNavigationRegion world,
|
||||
+ Mob mob,
|
||||
+ Set<BlockPos> positions,
|
||||
+ float followRange,
|
||||
+ int distance,
|
||||
+ float rangeMultiplier
|
||||
+ ) {
|
||||
+ if (!org.plazmamc.plazma.configurations.GlobalConfiguration.get().entity.asyncPathProcess.enabled) this.openSet.clear();
|
||||
+ NodeEvaluator evaluator = this.evaluatorGenerator == null
|
||||
+ ? this.nodeEvaluator
|
||||
+ : NodeEvaluatorCache.take(this.evaluatorGenerator, this.nodeEvaluator);
|
||||
+
|
||||
+ evaluator.prepare(world, mob);
|
||||
+ Node node = evaluator.getStart();
|
||||
+
|
||||
if (node == null) {
|
||||
+ NodeEvaluatorCache.remove(evaluator);
|
||||
return null;
|
||||
- if (node == null) {
|
||||
- return null;
|
||||
- } else {
|
||||
- // Paper start - Perf: remove streams and optimize collection
|
||||
- List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
@@ -1087,112 +1074,66 @@ index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a15399
|
||||
- map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
- }
|
||||
- // Paper end - Perf: remove streams and optimize collection
|
||||
- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
||||
- Path path = this.findPath(node, map, followRange, distance, rangeMultiplier);
|
||||
- this.nodeEvaluator.done();
|
||||
- return path;
|
||||
}
|
||||
+
|
||||
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
+ for (final BlockPos pos : positions)
|
||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(evaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
+
|
||||
+ if (this.evaluatorGenerator == null) {
|
||||
+ NodeEvaluatorCache.remove(evaluator);
|
||||
+ return this.findPath(node, map, followRange, distance, rangeMultiplier);
|
||||
+ }
|
||||
+
|
||||
+ return new AsyncPath(
|
||||
+ Lists.newArrayList(),
|
||||
+ positions,
|
||||
+ () -> this.processPath(evaluator, node, map, followRange, distance, rangeMultiplier),
|
||||
+ () -> {
|
||||
+ evaluator.done();
|
||||
+ NodeEvaluatorCache.returnEvaluator(evaluator);
|
||||
+ }
|
||||
+ );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
// Paper start - Perf: remove streams and optimize collection
|
||||
- private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
- //profiler.push("find_path"); // Purpur
|
||||
- //profiler.markForCharting(MetricCategory.PATH_FINDING); // Purpur
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- @Nullable
|
||||
- // Paper start - Perf: remove streams and optimize collection
|
||||
- private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
- //ProfilerFiller profilerFiller = Profiler.get(); // Purpur
|
||||
- //profilerFiller.push("find_path"); // Purpur
|
||||
- //profilerFiller.markForCharting(MetricCategory.PATH_FINDING); // Purpur
|
||||
- // Set<Target> set = positions.keySet();
|
||||
+ private Path findPath(
|
||||
+ Node startNode,
|
||||
+ List<Map.Entry<Target, BlockPos>> positions,
|
||||
+ float followRange,
|
||||
+ int distance,
|
||||
+ float rangeMultiplier
|
||||
+ ) {
|
||||
+ try {
|
||||
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
||||
+ } catch (Exception e) {
|
||||
+ LOGGER.error("Failed to process path", e);
|
||||
+ return null;
|
||||
+ } finally {
|
||||
+ this.nodeEvaluator.done();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @SuppressWarnings("DataFlowIssue")
|
||||
+ @org.jetbrains.annotations.NotNull
|
||||
+ private synchronized Path processPath(
|
||||
+ NodeEvaluator nodeEvaluator,
|
||||
+ Node startNode,
|
||||
+ List<Map.Entry<Target, BlockPos>> positions,
|
||||
+ float followRange,
|
||||
+ int distance,
|
||||
+ float rangeMultiplier
|
||||
+ ) {
|
||||
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty());
|
||||
startNode.g = 0.0F;
|
||||
startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
||||
startNode.f = startNode.h;
|
||||
this.openSet.clear();
|
||||
this.openSet.insert(startNode);
|
||||
- startNode.g = 0.0F;
|
||||
- startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
||||
- startNode.f = startNode.h;
|
||||
- this.openSet.clear();
|
||||
- this.openSet.insert(startNode);
|
||||
- // Set<Node> set2 = ImmutableSet.of(); // Paper - unused - diff on change
|
||||
+
|
||||
int i = 0;
|
||||
List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection
|
||||
int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
|
||||
- int i = 0;
|
||||
- List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection
|
||||
- int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
|
||||
+ if (ASYNC) this.openSet.clear();
|
||||
|
||||
while (!this.openSet.isEmpty()) {
|
||||
- while (!this.openSet.isEmpty()) {
|
||||
- if (++i >= j) {
|
||||
- break;
|
||||
- }
|
||||
+ if (++i >= j) break;
|
||||
+ NodeEvaluator evaluator = this.evaluatorGenerator == null ? this.nodeEvaluator : NodeEvaluatorCache.take(this.evaluatorGenerator, this.nodeEvaluator);
|
||||
+ evaluator.prepare(world, mob);
|
||||
|
||||
Node node = this.openSet.pop();
|
||||
node.closed = true;
|
||||
- Node node = this.openSet.pop();
|
||||
- node.closed = true;
|
||||
+ Node node = evaluator.getStart();
|
||||
+ if ( node == null ) {
|
||||
+ NodeEvaluatorCache.remove(evaluator);
|
||||
+ return null; // diff on change
|
||||
+ }
|
||||
|
||||
- // Paper start - optimize collection
|
||||
- for (int i1 = 0; i1 < positions.size(); i1++) {
|
||||
- final Map.Entry<Target, BlockPos> entry = positions.get(i1);
|
||||
+ for (final Map.Entry<Target, BlockPos> entry : positions) {
|
||||
Target target = entry.getKey();
|
||||
- Target target = entry.getKey();
|
||||
- if (node.distanceManhattan(target) <= (float)distance) {
|
||||
+ if (node.distanceManhattan(target) <= (float) distance) {
|
||||
target.setReached();
|
||||
entryList.add(entry);
|
||||
- target.setReached();
|
||||
- entryList.add(entry);
|
||||
- // Paper end - Perf: remove streams and optimize collection
|
||||
}
|
||||
}
|
||||
- }
|
||||
- }
|
||||
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
+ for (final BlockPos pos : positions)
|
||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(evaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
|
||||
- if (!entryList.isEmpty()) { // Paper - Perf: remove streams and optimize collection; rename
|
||||
- break;
|
||||
- }
|
||||
+ if (!entryList.isEmpty()) break;
|
||||
+ if (node.distanceTo(startNode) >= followRange) continue;
|
||||
+
|
||||
+ int k = nodeEvaluator.getNeighbors(this.neighbors, node);
|
||||
+
|
||||
+ for (int l = 0; l < k; l++) {
|
||||
+ Node node2 = this.neighbors[l];
|
||||
+ float f = this.distance(node, node2);
|
||||
+ node2.walkedDistance = node.walkedDistance + f;
|
||||
+ float g = node.g + f + node2.costMalus;
|
||||
+ if (node2.walkedDistance >= followRange || (node2.inOpenSet() && g >= node2.g)) continue;
|
||||
+ if (this.evaluatorGenerator == null) {
|
||||
+ NodeEvaluatorCache.remove(evaluator);
|
||||
+ return this.findPath(node, map, followRange, distance, rangeMultiplier);
|
||||
+ }
|
||||
|
||||
- if (!(node.distanceTo(startNode) >= followRange)) {
|
||||
- int k = this.nodeEvaluator.getNeighbors(this.neighbors, node);
|
||||
@@ -1213,26 +1154,124 @@ index 404080976208c30e9e95e5bee47c2a749e709a45..e31ee7508a1af51bec628141c3a15399
|
||||
- this.openSet.insert(node2);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ return new AsyncPath(
|
||||
+ Lists.newArrayList(),
|
||||
+ positions,
|
||||
+ () -> this.processPath(evaluator, node, map, followRange, distance, rangeMultiplier),
|
||||
+ () -> {
|
||||
+ evaluator.done();
|
||||
+ NodeEvaluatorCache.returnEvaluator(evaluator);
|
||||
}
|
||||
- }
|
||||
+ );
|
||||
+ }
|
||||
|
||||
- // Paper start - Perf: remove streams and optimize collection
|
||||
- Path best = null;
|
||||
- boolean entryListIsEmpty = entryList.isEmpty();
|
||||
- Comparator<Path> comparator = entryListIsEmpty ? Comparator.comparingInt(Path::getNodeCount)
|
||||
- : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
|
||||
- for (Map.Entry<Target, BlockPos> entry : entryListIsEmpty ? positions : entryList) {
|
||||
- Path path = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !entryListIsEmpty);
|
||||
- if (best == null || comparator.compare(path, best) < 0)
|
||||
- best = path;
|
||||
+ @Nullable
|
||||
+ // Paper start - Perf: remove streams and optimize collection
|
||||
+ private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
+ try {
|
||||
+ return this.processPath(this.nodeEvaluator, startNode, positions, followRange, distance, rangeMultiplier);
|
||||
+ } catch (Exception e) {
|
||||
+ LOGGER.error("Failed to process path", e);
|
||||
+ return null;
|
||||
+ } finally {
|
||||
+ this.nodeEvaluator.done();
|
||||
}
|
||||
- //profilerFiller.pop(); // Purpur
|
||||
- return best;
|
||||
- // Paper end - Perf: remove streams and optimize collection
|
||||
}
|
||||
|
||||
protected float distance(Node a, Node b) {
|
||||
@@ -164,4 +125,78 @@ public class PathFinder {
|
||||
|
||||
return new Path(list, target, reachesTarget);
|
||||
}
|
||||
+
|
||||
+ @Nullable
|
||||
+ private Path processPath(NodeEvaluator evaluator, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
+ org.apache.commons.lang3.Validate.isTrue(!positions.isEmpty());
|
||||
+
|
||||
+ startNode.g = 0.0F;
|
||||
+ startNode.h = this.getBestH(startNode, positions);
|
||||
+ startNode.f = startNode.h;
|
||||
+
|
||||
+ this.openSet.clear();
|
||||
+ this.openSet.insert(startNode);
|
||||
+
|
||||
+ int i = 0;
|
||||
+ int j = (int) (this.maxVisitedNodes * rangeMultiplier);
|
||||
+ List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size());
|
||||
+
|
||||
+ while (!this.openSet.isEmpty()) {
|
||||
+ if (++i >= j) break;
|
||||
+
|
||||
+ Node node = this.openSet.pop();
|
||||
+ node.closed = true;
|
||||
+
|
||||
+ for (final Map.Entry<Target, BlockPos> entry : positions) {
|
||||
+ Target target = entry.getKey();
|
||||
+ if (node.distanceManhattan(target) > distance) continue;
|
||||
+
|
||||
+ target.setReached();
|
||||
+ entryList.add(entry);
|
||||
+ }
|
||||
+
|
||||
+ if (!entryList.isEmpty()) break;
|
||||
+ if (node.distanceTo(startNode) >= followRange) continue;
|
||||
+
|
||||
+ int k = evaluator.getNeighbors(this.neighbors, node);
|
||||
+ for (int l = 0; l < k; l++) {
|
||||
+ Node node2 = this.neighbors[l];
|
||||
+
|
||||
+ float f = this.distance(node, node2);
|
||||
+ float g = node.g + f + node2.costMalus;
|
||||
+
|
||||
+ node2.walkedDistance = node.walkedDistance + f;
|
||||
+ if (node2.walkedDistance >= followRange && !(!node2.inOpenSet() || g < node2.g)) continue;
|
||||
+
|
||||
+ node2.cameFrom = node;
|
||||
+ node2.g = g;
|
||||
+ node2.h = this.getBestH(node2, positions) * 1.5F; // Paper - Perf: remove streams and optimize collection
|
||||
+ node2.h = this.getBestH(node2, positions) * 1.5F;
|
||||
+
|
||||
+ if (node2.inOpenSet()) {
|
||||
+ this.openSet.changeCost(node2, node2.g + node2.h);
|
||||
+ continue;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ node2.f = node2.g + node2.h;
|
||||
+ this.openSet.insert(node2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +174,7 @@ public class PathFinder {
|
||||
return best;
|
||||
// Paper end - Perf: remove streams and optimize collection
|
||||
}
|
||||
+ // Plazma end - Process pathfinding asynchronously
|
||||
|
||||
protected float distance(Node a, Node b) {
|
||||
return a.distanceTo(b);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ Path best = null;
|
||||
+ boolean isEmpty = entryList.isEmpty();
|
||||
+
|
||||
+ Comparator<Path> comparator = isEmpty
|
||||
+ ? Comparator.comparingInt(Path::getNodeCount)
|
||||
+ : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
|
||||
+
|
||||
+ for (final Map.Entry<Target, BlockPos> entry : isEmpty ? positions : entryList) {
|
||||
+ Path path = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !isEmpty);
|
||||
+ if (best != null && comparator.compare(path, best) >= 0) continue;
|
||||
+
|
||||
+ best = path;
|
||||
+ }
|
||||
+
|
||||
+ return best;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
index 6308822f819d7cb84c8070c8a7eec1a3f822114b..370540e48a5fd5693bf956ffbddccca58a1482f8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java
|
||||
@@ -1259,10 +1298,10 @@ index 1c83926923f50fb4da1a83dc91614c20a831555f..aec2d0f9a957be65d031957dbff874d8
|
||||
|
||||
Command.broadcastCommandMessage(sender, text("Successfully reloaded Plazma configuration files.", NamedTextColor.GREEN));
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index aa8b0a9b3d98e2c2fb1bd3c374cd2e742e6e17cf..516a4545b67a4bf0d37cee3d1e26772831944fe6 100644
|
||||
index cac12ad98eb0fa4dcc1b0f7f21d1eadd14ef7456..ab4ff76efbe4077691a0fde4043160ecbc4bc7dc 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -60,6 +60,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
@@ -70,6 +70,26 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public class Entity extends ConfigurationPart {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user