2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 19 Dec 2016 23:07:42 -0500
Subject: [PATCH] Prevent Pathfinding out of World Border
This prevents Entities from trying to run outside of the World Border
2021-06-12 09:24:28 +02:00
TODO: This doesn't prevent the pathfinder from using blocks outside the world border as nodes. We can fix this
by adding code to all overrides in:
NodeEvaluator:
public abstract BlockPathTypes getBlockPathType(BlockGetter world, int x, int y, int z);
to return BLOCKED if it is outside the world border.
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
2024-10-22 22:00:33 +02:00
index 1d5ce4caf99a3fb376b350968a6bd1ac8471ffec..436812c3bfe53358b4d76bb72d777d6661bb6d60 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
2024-10-22 22:00:33 +02:00
@@ -174,7 +174,7 @@ public abstract class PathNavigation {
2024-01-23 14:34:17 +01:00
// Paper start - EntityPathfindEvent
2021-06-11 14:02:28 +02:00
boolean copiedSet = false;
2021-06-12 09:24:28 +02:00
for (BlockPos possibleTarget : positions) {
2021-06-17 23:39:36 +02:00
- if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
2023-06-08 00:28:06 +02:00
io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
2021-06-11 14:02:28 +02:00
if (!copiedSet) {
copiedSet = true;