3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-22 06:20:06 +01:00
Paper/patches/server/0075-Do-not-load-chunks-for-Pathfinding.patch

69 Zeilen
3.8 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 31 Mar 2016 19:17:58 -0400
Subject: [PATCH] Do not load chunks for Pathfinding
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
2021-06-12 04:24:43 +02:00
index e6a2f836e70a267da36ec87e0df68e36bae3626c..6c063351c76e92a8a91142a12db846d1c1f11921 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
2021-06-12 04:24:43 +02:00
@@ -46,7 +46,7 @@ public abstract class PathNavigation {
2021-06-11 14:02:28 +02:00
private BlockPos targetPos;
private int reachRange;
2021-06-12 04:24:43 +02:00
private float maxVisitedNodesMultiplier = 1.0F;
2021-06-11 14:02:28 +02:00
- private final PathFinder pathFinder;
+ private final PathFinder pathFinder; public PathFinder getPathfinder() { return this.pathFinder; } // Paper - OBFHELPER
private boolean isStuck;
public PathNavigation(Mob mob, Level world) {
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
2021-06-12 04:24:43 +02:00
index e855754bdb8431efc06c77b42d9a90b870abab8d..800d464207026d145056b39b298045121342b899 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
2021-06-12 04:24:43 +02:00
@@ -21,7 +21,7 @@ public class PathFinder {
private static final float FUDGING = 1.5F;
2021-06-11 14:02:28 +02:00
private final Node[] neighbors = new Node[32];
private final int maxVisitedNodes;
- private final NodeEvaluator nodeEvaluator;
+ private final NodeEvaluator nodeEvaluator; public NodeEvaluator getPathfinder() { return this.nodeEvaluator; } // Paper - OBFHELPER
2021-06-12 04:24:43 +02:00
private static final boolean DEBUG = false;
2021-06-11 14:02:28 +02:00
private final BinaryHeap openSet = new BinaryHeap();
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
2021-06-12 04:24:43 +02:00
index 204ed5665adf2df7252fe2d21872db6956415311..b37acb6e6e253529a38f44a518a02c7747d3145e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
2021-06-12 04:24:43 +02:00
@@ -453,7 +453,12 @@ public class WalkNodeEvaluator extends NodeEvaluator {
for(int n = -1; n <= 1; ++n) {
if (l != 0 || n != 0) {
pos.set(i + l, j + m, k + n);
- BlockState blockState = world.getBlockState(pos);
2021-06-11 14:02:28 +02:00
+ // Paper start
2021-06-12 04:24:43 +02:00
+ BlockState blockState = world.getTypeIfLoaded(pos);
+ if (blockState == null) {
+ return BlockPathTypes.BLOCKED;
2021-06-11 14:02:28 +02:00
+ } else {
+ // Paper end
2021-06-12 04:24:43 +02:00
if (blockState.is(Blocks.CACTUS)) {
2021-06-11 14:02:28 +02:00
return BlockPathTypes.DANGER_CACTUS;
2021-06-12 04:24:43 +02:00
}
@@ -469,6 +474,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
if (world.getFluidState(pos).is(FluidTags.WATER)) {
2021-06-11 14:02:28 +02:00
return BlockPathTypes.WATER_BORDER;
}
+ } // Paper
}
}
}
2021-06-12 04:24:43 +02:00
@@ -478,7 +484,8 @@ public class WalkNodeEvaluator extends NodeEvaluator {
2021-06-11 14:02:28 +02:00
}
2021-06-12 04:24:43 +02:00
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) {
- BlockState blockState = world.getBlockState(pos);
+ BlockState blockState = world.getTypeIfLoaded(pos); // Paper
+ if (blockState == null) return BlockPathTypes.BLOCKED; // Paper
Block block = blockState.getBlock();
Material material = blockState.getMaterial();
if (blockState.isAir()) {