2021-06-11 12:02:28 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2021-07-07 17:18:05 +00:00
|
|
|
From: kennytv <jahnke.nassim@gmail.com>
|
2021-06-11 12:02:28 +00:00
|
|
|
Date: Fri, 29 Jan 2021 15:13:11 +0100
|
|
|
|
Subject: [PATCH] Add dropLeash variable to EntityUnleashEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
2022-01-09 05:12:05 +00:00
|
|
|
index e803af4d27f3f005a56696175d7ae8a51d7005a6..79c298334a1a2171ef6aca94114edf72ffb67ba1 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
2021-12-08 18:25:57 +00:00
|
|
|
@@ -1230,12 +1230,15 @@ public abstract class Mob extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
return InteractionResult.PASS;
|
|
|
|
} else if (this.getLeashHolder() == player) {
|
|
|
|
// CraftBukkit start - fire PlayerUnleashEntityEvent
|
|
|
|
- if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player).isCancelled()) {
|
|
|
|
+ // Paper start - drop leash variable
|
2021-06-14 19:58:32 +00:00
|
|
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, !player.getAbilities().instabuild);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ // Paper end
|
|
|
|
((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-06-14 19:58:32 +00:00
|
|
|
- this.dropLeash(true, !player.getAbilities().instabuild);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.dropLeash(true, event.isDropLeash()); // Paper - drop leash variable
|
|
|
|
return InteractionResult.sidedSuccess(this.level.isClientSide);
|
|
|
|
} else {
|
|
|
|
InteractionResult enuminteractionresult = this.checkAndHandleImportantInteractions(player, hand);
|
2021-12-08 18:25:57 +00:00
|
|
|
@@ -1393,8 +1396,11 @@ public abstract class Mob extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
if (this.leashHolder != null) {
|
|
|
|
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
|
|
|
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE, true);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-12-08 18:25:57 +00:00
|
|
|
@@ -1457,8 +1463,11 @@ public abstract class Mob extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
boolean flag1 = super.startRiding(entity, force);
|
|
|
|
|
|
|
|
if (flag1 && this.isLeashed()) {
|
|
|
|
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag1;
|
2022-01-01 03:05:42 +00:00
|
|
|
@@ -1630,8 +1639,11 @@ public abstract class Mob extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
@Override
|
|
|
|
protected void removeAfterChangingDimensions() {
|
|
|
|
super.removeAfterChangingDimensions();
|
|
|
|
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
|
|
|
- this.dropLeash(true, false);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, false);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
2021-06-14 19:58:32 +00:00
|
|
|
this.getAllSlots().forEach((itemstack) -> {
|
|
|
|
if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit
|
|
|
|
});
|
2021-06-11 12:02:28 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
2021-11-24 19:33:17 +00:00
|
|
|
index 999d18610666ec442bb038da5c452e3cd77e7428..5f256c1ac5d49e19cfccf174dd55506313c493e0 100644
|
2021-06-11 12:02:28 +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 19:33:17 +00:00
|
|
|
@@ -49,8 +49,11 @@ public abstract class PathfinderMob extends Mob {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
if (this instanceof TamableAnimal && ((TamableAnimal) this).isInSittingPose()) {
|
|
|
|
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
|
|
|
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2021-11-24 19:33:17 +00:00
|
|
|
@@ -58,8 +61,11 @@ public abstract class PathfinderMob extends Mob {
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
this.onLeashDistance(f);
|
|
|
|
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
|
|
|
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
|
|
|
- this.dropLeash(true, true);
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
|
|
|
+ this.dropLeash(true, event.isDropLeash());
|
|
|
|
+ // Paper end
|
|
|
|
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
|
|
|
} else if (f > 6.0F) {
|
|
|
|
double d0 = (entity.getX() - this.getX()) / (double) f;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
2021-11-24 19:33:17 +00:00
|
|
|
index cf932116a0cafd315e44159fbf7c5d25d43782ff..03bda898a5a263053ecd79f74799d37095bbeb54 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
2021-06-14 19:58:32 +00:00
|
|
|
@@ -123,11 +123,14 @@ public class LeashFenceKnotEntity extends HangingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
entityinsentient = (Mob) iterator.next();
|
|
|
|
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
|
|
|
|
// CraftBukkit start
|
|
|
|
- if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player).isCancelled()) {
|
|
|
|
+ // Paper start - drop leash variable
|
2021-06-14 19:58:32 +00:00
|
|
|
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player, !player.getAbilities().instabuild);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ // Paper end
|
|
|
|
die = false;
|
|
|
|
continue;
|
|
|
|
}
|
2021-06-14 19:58:32 +00:00
|
|
|
- entityinsentient.dropLeash(true, !player.getAbilities().instabuild); // false -> survival mode boolean
|
2021-06-11 12:02:28 +00:00
|
|
|
+ entityinsentient.dropLeash(true, event.isDropLeash()); // false -> survival mode boolean // Paper - drop leash variable
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2022-01-23 00:59:56 +00:00
|
|
|
index 5b9e76fbffa74b29f1a21374a74f46c917104fea..7cde66a83f4abd4b25b7615139b1dd1cb2c746ce 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2022-01-23 00:59:56 +00:00
|
|
|
@@ -1516,8 +1516,10 @@ public class CraftEventFactory {
|
2021-06-11 12:02:28 +00:00
|
|
|
return itemInHand;
|
|
|
|
}
|
|
|
|
|
|
|
|
- public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player) {
|
|
|
|
- PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity());
|
|
|
|
+ // Paper start - drop leash variable
|
|
|
|
+ public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, boolean dropLeash) {
|
|
|
|
+ PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), dropLeash);
|
|
|
|
+ // Paper end
|
|
|
|
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
|
|
|
return event;
|
|
|
|
}
|