aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0112-Prevent-Pathfinding-out-of-World-Border.patch
blob: f473b6a56e97af5c3fb5bc0fb2e607b58c6bbc8a (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
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

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.

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
index 85b3da93b6dd8e1a40d884db0721f30b9b237c69..c3b406e6302ae0ac1ef56253ab614ca201a7a1c8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
@@ -159,7 +159,7 @@ public abstract class PathNavigation {
             // Paper start - EntityPathfindEvent
             boolean copiedSet = false;
             for (BlockPos possibleTarget : positions) {
-                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
                     io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
                     if (!copiedSet) {
                         copiedSet = true;