3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 11:30:06 +01:00
Paper/Spigot-Server-Patches/0078-Do-not-load-chunks-for-Pathfinding.patch
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00

85 Zeilen
4.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/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java
index 53c15c1c0bf2d902e6b0325e0964f88f6d5fd6a5..29c66b983dc503903a76bab753bb9035ec10f54c 100644
--- a/src/main/java/net/minecraft/server/ChunkCache.java
+++ b/src/main/java/net/minecraft/server/ChunkCache.java
@@ -27,7 +27,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
for (k = this.a; k <= i; ++k) {
for (l = this.b; l <= j; ++l) {
- this.c[k - this.a][l - this.b] = ichunkprovider.a(k, l);
+ this.c[k - this.a][l - this.b] = world.getChunkIfLoadedImmediately(k, l); // Paper
}
}
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 5e7158ba1053ae77fc5c5811d49214e877a5fe30..39a0c45bb0e3d2fcfbcc07192f9e1e61570c922e 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -28,7 +28,7 @@ public abstract class NavigationAbstract {
private BlockPosition q;
private int r;
private float s;
- private final Pathfinder t;
+ private final Pathfinder t; public Pathfinder getPathfinder() { return this.t; } // Paper - OBFHELPER
public NavigationAbstract(EntityInsentient entityinsentient, World world) {
this.g = Vec3D.a;
diff --git a/src/main/java/net/minecraft/server/Pathfinder.java b/src/main/java/net/minecraft/server/Pathfinder.java
index 6199570618d4642b7ca7b2472852cec6af0202d9..67c63cfe333e328cbd00ada970bd81efebfe30b6 100644
--- a/src/main/java/net/minecraft/server/Pathfinder.java
+++ b/src/main/java/net/minecraft/server/Pathfinder.java
@@ -19,7 +19,7 @@ public class Pathfinder {
private final Set<PathPoint> b = Sets.newHashSet();
private final PathPoint[] c = new PathPoint[32];
private final int d;
- private final PathfinderAbstract e;
+ private final PathfinderAbstract e; public PathfinderAbstract getPathfinder() { return this.e; } // Paper - OBFHELPER
public Pathfinder(PathfinderAbstract pathfinderabstract, int i) {
this.e = pathfinderabstract;
diff --git a/src/main/java/net/minecraft/server/PathfinderNormal.java b/src/main/java/net/minecraft/server/PathfinderNormal.java
index ef248ebcc4419609836c2025548aefb3afcf27d1..4240ca81cb6debecc54dcf9a550e9d916dfa8f9f 100644
--- a/src/main/java/net/minecraft/server/PathfinderNormal.java
+++ b/src/main/java/net/minecraft/server/PathfinderNormal.java
@@ -365,7 +365,8 @@ public class PathfinderNormal extends PathfinderAbstract {
PathType pathtype = c(iblockaccess, i, j, k);
if (pathtype == PathType.OPEN && j >= 1) {
- Block block = iblockaccess.getType(new BlockPosition(i, j - 1, k)).getBlock();
+ Block block = iblockaccess.getBlockIfLoaded(new BlockPosition(i, j - 1, k)); // Paper
+ if (block == null) return PathType.BLOCKED; // Paper
PathType pathtype1 = c(iblockaccess, i, j - 1, k);
pathtype = pathtype1 != PathType.WALKABLE && pathtype1 != PathType.OPEN && pathtype1 != PathType.WATER && pathtype1 != PathType.LAVA ? PathType.WALKABLE : PathType.OPEN;
@@ -402,8 +403,12 @@ public class PathfinderNormal extends PathfinderAbstract {
for (int i1 = -1; i1 <= 1; ++i1) {
for (int j1 = -1; j1 <= 1; ++j1) {
if (l != 0 || j1 != 0) {
- Block block = iblockaccess.getType(blockposition_pooledblockposition.d(l + i, i1 + j, j1 + k)).getBlock();
-
+ // Paper start
+ Block block = iblockaccess.getBlockIfLoaded(blockposition_pooledblockposition.d(l + i, i1 + j, j1 + k));
+ if (block == null) {
+ pathtype = PathType.BLOCKED;
+ } else
+ // Paper end
if (block == Blocks.CACTUS) {
pathtype = PathType.DANGER_CACTUS;
} else if (block != Blocks.FIRE && block != Blocks.LAVA) {
@@ -440,7 +445,8 @@ public class PathfinderNormal extends PathfinderAbstract {
protected static PathType c(IBlockAccess iblockaccess, int i, int j, int k) {
BlockPosition blockposition = new BlockPosition(i, j, k);
- IBlockData iblockdata = iblockaccess.getType(blockposition);
+ IBlockData iblockdata = iblockaccess.getTypeIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return PathType.BLOCKED; // Paper
Block block = iblockdata.getBlock();
Material material = iblockdata.getMaterial();