PaperMC/patches/server-remapped/Do-not-load-chunks-for-Pathfinding.patch
MiniDigger | Martin 95d25d98e8 Move patches around
2021-06-11 14:02:28 +02:00

68 lines
3.9 KiB
Diff

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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
@@ -0,0 +0,0 @@ public abstract class PathNavigation {
private BlockPos targetPos;
private int reachRange;
private float maxVisitedNodesMultiplier;
- 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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
@@ -0,0 +0,0 @@ public class PathFinder {
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
private final BinaryHeap openSet = new BinaryHeap();
public PathFinder(NodeEvaluator pathNodeMaker, int range) {
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
for (int j1 = -1; j1 <= 1; ++j1) {
if (l != 0 || j1 != 0) {
blockposition_mutableblockposition.set(i + l, j + i1, k + j1);
- BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition);
+ // Paper start
+ BlockState iblockdata = iblockaccess.getTypeIfLoaded(blockposition_mutableblockposition);
+ if (iblockdata == null) {
+ pathtype = BlockPathTypes.BLOCKED;
+ } else {
+ // Paper end
if (iblockdata.is(Blocks.CACTUS)) {
return BlockPathTypes.DANGER_CACTUS;
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
if (iblockaccess.getFluidState(blockposition_mutableblockposition).is((Tag) FluidTags.WATER)) {
return BlockPathTypes.WATER_BORDER;
}
+ } // Paper
}
}
}
@@ -0,0 +0,0 @@ public class WalkNodeEvaluator extends NodeEvaluator {
}
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter iblockaccess, BlockPos blockposition) {
- BlockState iblockdata = iblockaccess.getBlockState(blockposition);
+ BlockState iblockdata = iblockaccess.getTypeIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return BlockPathTypes.BLOCKED; // Paper
Block block = iblockdata.getBlock();
Material material = iblockdata.getMaterial();