mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 04:25:26 +01:00
43 lines
2.4 KiB
Diff
43 lines
2.4 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/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
|
index 13840b12e209b62783206861b817d433eedd6191..b125b9903454891e22a15a0a794d67be67fdb083 100644
|
|
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
|
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
|
@@ -469,7 +469,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);
|
|
+ // Paper start - Do not load chunks during pathfinding
|
|
+ BlockState blockState = world.getBlockStateIfLoaded(pos);
|
|
+ if (blockState == null) {
|
|
+ return BlockPathTypes.BLOCKED;
|
|
+ } else {
|
|
+ // Paper end - Do not load chunks during pathfinding
|
|
if (blockState.is(Blocks.CACTUS) || blockState.is(Blocks.SWEET_BERRY_BUSH)) {
|
|
return BlockPathTypes.DANGER_OTHER;
|
|
}
|
|
@@ -485,6 +490,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
|
if (blockState.is(Blocks.WITHER_ROSE) || blockState.is(Blocks.POINTED_DRIPSTONE)) {
|
|
return BlockPathTypes.DAMAGE_CAUTIOUS;
|
|
}
|
|
+ } // Paper
|
|
}
|
|
}
|
|
}
|
|
@@ -494,7 +500,8 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
|
}
|
|
|
|
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) {
|
|
- BlockState blockState = world.getBlockState(pos);
|
|
+ BlockState blockState = world.getBlockStateIfLoaded(pos); // Paper - Do not load chunks during pathfinding
|
|
+ if (blockState == null) return BlockPathTypes.BLOCKED; // Paper - Do not load chunks during pathfinding
|
|
Block block = blockState.getBlock();
|
|
if (blockState.isAir()) {
|
|
return BlockPathTypes.OPEN;
|