Do not remove leash knot if leasing to an existing leash knot gets cancelled

This commit is contained in:
DerFrZocker 2024-04-28 07:27:18 +10:00 committed by md_5
parent f70367d429
commit 996f660f3f
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -14,20 +14,21 @@
public class EntityLeash extends EntityHanging {
public static final double OFFSET_Y = 0.375D;
@@ -89,6 +96,12 @@
@@ -89,6 +96,13 @@
EntityInsentient entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman, enumhand).isCancelled()) {
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ flag = true; // Also set true when the event is cancelled otherwise it tries to unleash the entities
+ continue;
+ }
+ // CraftBukkit end
entityinsentient.setLeashedTo(this, true);
flag = true;
}
@@ -97,18 +110,32 @@
@@ -97,18 +111,32 @@
boolean flag1 = false;
if (!flag) {