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-12-07 17:46:46 +01:00
|
|
|
index 965dd5564d64c094ffc1347621a45d50c6c5f1e3..147ec41ae4a3b9e9ad495ab4309c9f7306122749 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-09-12 13:31:45 +02:00
|
|
|
@@ -1488,7 +1488,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);
|