2021-08-13 18:15:43 +00:00
|
|
|
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
|
2022-09-12 11:31:45 +00:00
|
|
|
index e08d69af81f4ca0535be522eef4792e4127f454c..5fb88a3b7242a2712a568aaccebe601f89bfee3a 100644
|
2021-08-13 18:15:43 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
2022-09-12 11:31:45 +00:00
|
|
|
@@ -1488,7 +1488,7 @@ public abstract class Mob extends LivingEntity {
|
2021-08-13 18:15:43 +00:00
|
|
|
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
|
2022-06-09 08:51:45 +00:00
|
|
|
index f5cb3576aa2560c86f4a1df9d51d8ecde4e98905..7b2a81f9a79c5e96beba44ffe9b56a305ac2404f 100644
|
2021-08-13 18:15:43 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
2021-11-24 23:46:26 +00:00
|
|
|
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
|
2022-06-09 08:51:45 +00:00
|
|
|
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
2021-08-13 18:15:43 +00:00
|
|
|
// 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
|
|
|
|
}
|
2021-11-24 23:46:26 +00:00
|
|
|
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
|
2022-06-09 08:51:45 +00:00
|
|
|
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
2021-08-13 18:15:43 +00:00
|
|
|
// 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);
|