aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0713-Make-EntityUnleashEvent-cancellable.patch
blob: 76356ad12277487f788e93b27ef7b990aa4afbf6 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
index 6604cd4c65abd591a93620a1928e7b2635f0a38e..0a559b658cd52a1cce2895c6d9f96aa665a85c7b 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1465,7 +1465,7 @@ public abstract class Mob extends LivingEntity {
         if (flag1 && this.isLeashed()) {
             // Paper start - drop leash variable
             EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), 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
index 5f256c1ac5d49e19cfccf174dd55506313c493e0..744a99151ceecc85349861a99f6cb65e04c41b73 100644
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
                 if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
                     // Paper start - drop leash variable
                     EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
-                    this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+                    if (!event.callEvent()) { return; }
                     this.dropLeash(true, event.isDropLeash());
                     // Paper end
                 }
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
             if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
                 // Paper start - drop leash variable
                 EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
-                this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+                if (!event.callEvent()) return;
                 this.dropLeash(true, event.isDropLeash());
                 // Paper end
                 this.goalSelector.disableControlFlag(Goal.Flag.MOVE);