summaryrefslogtreecommitdiffstats
path: root/nms-patches/PathfinderNormal.patch
blob: 1beacfe24f20de66e8e8afe96a6eeec29aec5758 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--- a/net/minecraft/server/PathfinderNormal.java
+++ b/net/minecraft/server/PathfinderNormal.java
@@ -3,6 +3,7 @@
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
+import javax.annotation.Nullable;
 
 public class PathfinderNormal extends PathfinderAbstract {
 
@@ -16,8 +17,8 @@
     }
 
     public void a() {
-        super.a();
         this.b.a(PathType.WATER, this.j);
+        super.a();
     }
 
     public PathPoint b() {
@@ -140,6 +141,7 @@
         return i;
     }
 
+    @Nullable
     private PathPoint a(int i, int j, int k, int l, double d0, EnumDirection enumdirection) {
         PathPoint pathpoint = null;
         BlockPosition blockposition = new BlockPosition(i, j, k);
@@ -287,70 +289,42 @@
     }
 
     public static PathType a(IBlockAccess iblockaccess, int i, int j, int k) {
-        BlockPosition blockposition = new BlockPosition(i, j, k);
-        IBlockData iblockdata = iblockaccess.getType(blockposition);
-        Block block = iblockdata.getBlock();
-        Material material = iblockdata.getMaterial();
-        PathType pathtype = PathType.BLOCKED;
+        PathType pathtype = b(iblockaccess, i, j, k);
 
-        if (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY) {
-            if (block == Blocks.FIRE) {
-                return PathType.DAMAGE_FIRE;
-            } else if (block == Blocks.CACTUS) {
-                return PathType.DAMAGE_CACTUS;
-            } else if (block instanceof BlockDoor && material == Material.WOOD && !((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
-                return PathType.DOOR_WOOD_CLOSED;
-            } else if (block instanceof BlockDoor && material == Material.ORE && !((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
-                return PathType.DOOR_IRON_CLOSED;
-            } else if (block instanceof BlockDoor && ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
-                return PathType.DOOR_OPEN;
-            } else if (block instanceof BlockMinecartTrackAbstract) {
-                return PathType.RAIL;
-            } else if (!(block instanceof BlockFence) && !(block instanceof BlockCobbleWall) && (!(block instanceof BlockFenceGate) || ((Boolean) iblockdata.get(BlockFenceGate.OPEN)).booleanValue())) {
-                if (material == Material.AIR) {
-                    pathtype = PathType.OPEN;
-                } else {
-                    if (material == Material.WATER) {
-                        return PathType.WATER;
-                    }
+        if (pathtype == PathType.OPEN && j >= 1) {
+            PathType pathtype1 = b(iblockaccess, i, j - 1, k);
 
-                    if (material == Material.LAVA) {
-                        return PathType.LAVA;
-                    }
-                }
+            pathtype = pathtype1 != PathType.WALKABLE && pathtype1 != PathType.OPEN && pathtype1 != PathType.WATER && pathtype1 != PathType.LAVA ? PathType.WALKABLE : PathType.OPEN;
+        }
 
-                if (block.b(iblockaccess, blockposition) && pathtype == PathType.BLOCKED) {
-                    pathtype = PathType.OPEN;
-                }
+        BlockPosition.PooledBlockPosition blockposition_pooledblockposition = BlockPosition.PooledBlockPosition.s();
 
-                if (pathtype == PathType.OPEN && j >= 1) {
-                    PathType pathtype1 = a(iblockaccess, i, j - 1, k);
+        if (pathtype == PathType.WALKABLE) {
+            for (int l = -1; l <= 1; ++l) {
+                for (int i1 = -1; i1 <= 1; ++i1) {
+                    if (l != 0 || i1 != 0) {
+                        Block block = iblockaccess.getType(blockposition_pooledblockposition.d(l + i, j, i1 + k)).getBlock();
 
-                    pathtype = pathtype1 != PathType.WALKABLE && pathtype1 != PathType.OPEN && pathtype1 != PathType.WATER && pathtype1 != PathType.LAVA ? PathType.WALKABLE : PathType.OPEN;
-                }
-
-                if (pathtype == PathType.WALKABLE) {
-                    for (int l = i - 1; l <= i + 1; ++l) {
-                        for (int i1 = k - 1; i1 <= k + 1; ++i1) {
-                            if (l != i || i1 != k) {
-                                Block block1 = iblockaccess.getType(new BlockPosition(l, j, i1)).getBlock();
-
-                                if (block1 == Blocks.CACTUS) {
-                                    pathtype = PathType.DANGER_CACTUS;
-                                } else if (block1 == Blocks.FIRE) {
-                                    pathtype = PathType.DANGER_FIRE;
-                                }
-                            }
+                        if (block == Blocks.CACTUS) {
+                            pathtype = PathType.DANGER_CACTUS;
+                        } else if (block == Blocks.FIRE) {
+                            pathtype = PathType.DANGER_FIRE;
                         }
                     }
                 }
-
-                return pathtype;
-            } else {
-                return PathType.FENCE;
             }
-        } else {
-            return PathType.TRAPDOOR;
         }
+
+        blockposition_pooledblockposition.t();
+        return pathtype;
+    }
+
+    private static PathType b(IBlockAccess iblockaccess, int i, int j, int k) {
+        BlockPosition blockposition = new BlockPosition(i, j, k);
+        IBlockData iblockdata = iblockaccess.getType(blockposition);
+        Block block = iblockdata.getBlock();
+        Material material = iblockdata.getMaterial();
+
+        return material == Material.AIR ? PathType.OPEN : (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY ? (block == Blocks.FIRE ? PathType.DAMAGE_FIRE : (block == Blocks.CACTUS ? PathType.DAMAGE_CACTUS : (block instanceof BlockDoor && material == Material.WOOD && !((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue() ? PathType.DOOR_WOOD_CLOSED : (block instanceof BlockDoor && material == Material.ORE && !((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue() ? PathType.DOOR_IRON_CLOSED : (block instanceof BlockDoor && ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue() ? PathType.DOOR_OPEN : (block instanceof BlockMinecartTrackAbstract ? PathType.RAIL : (!(block instanceof BlockFence) && !(block instanceof BlockCobbleWall) && (!(block instanceof BlockFenceGate) || ((Boolean) iblockdata.get(BlockFenceGate.OPEN)).booleanValue()) ? (material == Material.WATER ? PathType.WATER : (material == Material.LAVA ? PathType.LAVA : (block.b(iblockaccess, blockposition) ? PathType.OPEN : PathType.BLOCKED))) : PathType.FENCE))))))) : PathType.TRAPDOOR);
     }
 }