42 lines
2.6 KiB
Diff
42 lines
2.6 KiB
Diff
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 0582c118b6206406764d1ea83ca6289cbb0a1392..11f3a492748d291c9c58c09d6ed62188f0868438 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -1482,7 +1482,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 41fa86e009a6bc2faf32a211639e8bc6a40bb00c..32cd54c9154f43824e2f05ab277321cde26d6545 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);
|