mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
42 lines
2.7 KiB
Diff
42 lines
2.7 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 3fbdd1b01bc86696b958ca6b7a3848e72fb51d50..00c6605f06773c52f6f5c5c1f5bcdd6dd67fb5b6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -1541,7 +1541,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
|
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 e49fb8be7d3975506a6c39c87cace664e45b3c86..a53466a84973f5e83afc71245b317ab4296e0f9e 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().misc.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().misc.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);
|