pathfinding, packet utils

This commit is contained in:
Noah van der Aa
2024-12-13 18:56:07 +01:00
parent e20952c643
commit 18a25937bc
5 changed files with 18 additions and 35 deletions

View File

@@ -1,10 +0,0 @@
--- a/net/minecraft/world/level/pathfinder/Path.java
+++ b/net/minecraft/world/level/pathfinder/Path.java
@@ -18,6 +18,7 @@
private final BlockPos target;
private final float distToTarget;
private final boolean reached;
+ public boolean hasNext() { return getNextNodeIndex() < this.nodes.size(); } // Paper - Mob Pathfinding API
public Path(List<Node> nodes, BlockPos target, boolean reachesTarget) {
this.nodes = nodes;

View File

@@ -1,16 +0,0 @@
--- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
@@ -478,7 +478,12 @@
}
protected static PathType getPathTypeFromState(BlockGetter world, BlockPos pos) {
- BlockState blockState = world.getBlockState(pos);
+ // Paper start - Do not load chunks during pathfinding
+ BlockState blockState = world.getBlockStateIfLoaded(pos);
+ if (blockState == null) {
+ return PathType.BLOCKED;
+ }
+ // Paper end
Block block = blockState.getBlock();
if (blockState.isAir()) {
return PathType.OPEN;