aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0082-Do-not-load-chunks-for-Pathfinding.patch
blob: 5d5acfa445b3b0d5ccd9d7c52c1a1ebf4a5ff906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 cd6778fa1d4261caf846ae71702621d2ec6b98c1..8e90b284fb576738b834626bb52c9962ccbc5ad2 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
@@ -465,7 +465,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
+                        BlockState blockState = world.getBlockStateIfLoaded(pos);
+                        if (blockState == null) {
+                            return BlockPathTypes.BLOCKED;
+                        } else {
+                        // Paper end
                         if (blockState.is(Blocks.CACTUS) || blockState.is(Blocks.SWEET_BERRY_BUSH)) {
                             return BlockPathTypes.DANGER_OTHER;
                         }
@@ -481,6 +486,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
                         if (blockState.is(Blocks.WITHER_ROSE) || blockState.is(Blocks.POINTED_DRIPSTONE)) {
                             return BlockPathTypes.DAMAGE_CAUTIOUS;
                         }
+                        } // Paper
                     }
                 }
             }
@@ -490,7 +496,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
+        if (blockState == null) return BlockPathTypes.BLOCKED; // Paper
         Block block = blockState.getBlock();
         if (blockState.isAir()) {
             return BlockPathTypes.OPEN;