Paper/patches/server/0637-Make-EntityUnleashEvent-cancellable.patch

42 lines
2.7 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 3 Jan 2021 21:25:31 -0800
Subject: [PATCH] Make EntityUnleashEvent cancellable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
2023-12-06 05:46:41 +01:00
index 764a5dd85e3fb581b1e713ce9b148be1874d55be..16d84042e2575418880897c728a99d1b8bbcdd15 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
2023-12-06 05:46:41 +01:00
@@ -1550,7 +1550,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
if (flag1 && this.isLeashed()) {
// Paper start - drop leash variable
2023-06-08 04:04:01 +02:00
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+ if (!event.callEvent()) { return flag1; }
this.dropLeash(true, event.isDropLeash());
// Paper end
}
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
2023-09-22 14:22:24 +02:00
index 8e362ad31208d87f4a69a1747485610e0588be51..463b72cab6a62e9738b33007728b2b00ae12e1bc 100644
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
2023-09-22 14:22:24 +02:00
@@ -59,7 +59,7 @@ public abstract class PathfinderMob extends Mob {
2023-06-08 04:04:01 +02:00
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
// Paper start - drop leash variable
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
2023-06-08 04:04:01 +02:00
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+ if (!event.callEvent()) { return; }
this.dropLeash(true, event.isDropLeash());
// Paper end
}
2023-09-22 14:22:24 +02:00
@@ -71,7 +71,7 @@ public abstract class PathfinderMob extends Mob {
2023-06-08 04:04:01 +02:00
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
// Paper start - drop leash variable
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
2023-06-08 04:04:01 +02:00
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+ if (!event.callEvent()) { return; }
this.dropLeash(true, event.isDropLeash());
// Paper end
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);