2021-08-13 20:15:43 +02: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-06-09 10:51:45 +02:00
|
|
|
index 837c0a8bd15388bdb60d6950a437640459adde3c..a49dfe4f81d449c5dd7ba5b8f9af7fec5c54f5de 100644
|
2021-08-13 20:15:43 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
2022-06-08 12:20:57 +02:00
|
|
|
@@ -1482,7 +1482,7 @@ public abstract class Mob extends LivingEntity {
|
2021-08-13 20:15:43 +02: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 10:51:45 +02:00
|
|
|
index f5cb3576aa2560c86f4a1df9d51d8ecde4e98905..7b2a81f9a79c5e96beba44ffe9b56a305ac2404f 100644
|
2021-08-13 20:15:43 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
2021-11-25 00:46:26 +01:00
|
|
|
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
|
2022-06-09 10:51:45 +02:00
|
|
|
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
2021-08-13 20:15:43 +02: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-25 00:46:26 +01:00
|
|
|
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
|
2022-06-09 10:51:45 +02:00
|
|
|
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
2021-08-13 20:15:43 +02: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);
|