testserver/patches/server/0115-Prevent-Pathfinding-ou...

28 lines
1.8 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
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 12:02:28 +00: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
index b6b6106ad2105c19273dc9f983fabd6573d35e5a..185f0bce91f03dfe9a37412710aa7319a15f57ff 100644
2021-06-11 12:02:28 +00: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
2022-09-20 21:06:11 +00:00
@@ -156,7 +156,7 @@ public abstract class PathNavigation {
2021-06-11 12:02:28 +00:00
// Paper start - Pathfind event
boolean copiedSet = false;
for (BlockPos possibleTarget : positions) {
2021-06-17 21:39:36 +00: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
io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
2021-06-11 12:02:28 +00:00
if (!copiedSet) {
copiedSet = true;