SPIGOT-7615: PlayerLeashEntityEvent cancelled eats lead
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -259,12 +259,13 @@
|
||||
this.dropLeash(true, !entityhuman.hasInfiniteMaterials());
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
@@ -1336,6 +1434,12 @@
|
||||
@@ -1336,6 +1434,13 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
|
||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman, enumhand).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
@@ -272,7 +273,7 @@
|
||||
this.setLeashedTo(entityhuman, true);
|
||||
itemstack.shrink(1);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
@@ -1351,7 +1455,7 @@
|
||||
@@ -1351,7 +1456,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.level() instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
@@ -281,7 +282,7 @@
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
|
||||
@@ -1401,12 +1505,19 @@
|
||||
@@ -1401,12 +1506,19 @@
|
||||
return this.restrictRadius != -1.0F;
|
||||
}
|
||||
|
||||
@@ -302,7 +303,7 @@
|
||||
|
||||
if (t0 == null) {
|
||||
return null;
|
||||
@@ -1440,7 +1551,12 @@
|
||||
@@ -1440,7 +1552,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +317,7 @@
|
||||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
@@ -1448,7 +1564,7 @@
|
||||
@@ -1448,7 +1565,7 @@
|
||||
t0.startRiding(entity, true);
|
||||
}
|
||||
|
||||
@@ -325,7 +326,7 @@
|
||||
return t0;
|
||||
}
|
||||
}
|
||||
@@ -1461,7 +1577,8 @@
|
||||
@@ -1461,7 +1578,8 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
@@ -335,7 +336,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1473,7 +1590,9 @@
|
||||
@@ -1473,7 +1591,9 @@
|
||||
this.delayedLeashInfo = null;
|
||||
this.clearRestriction();
|
||||
if (!this.level().isClientSide && flag1) {
|
||||
@@ -345,7 +346,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) {
|
||||
@@ -1527,6 +1646,7 @@
|
||||
@@ -1527,6 +1647,7 @@
|
||||
boolean flag1 = super.startRiding(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
@@ -353,7 +354,7 @@
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -1555,7 +1675,9 @@
|
||||
@@ -1555,7 +1676,9 @@
|
||||
}
|
||||
|
||||
if (this.tickCount > 100) {
|
||||
@@ -363,7 +364,7 @@
|
||||
this.delayedLeashInfo = null;
|
||||
}
|
||||
}
|
||||
@@ -1638,14 +1760,21 @@
|
||||
@@ -1638,14 +1761,21 @@
|
||||
int i = EnchantmentManager.getFireAspect(this);
|
||||
|
||||
if (i > 0) {
|
||||
@@ -387,7 +388,7 @@
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
||||
}
|
||||
|
||||
@@ -1695,6 +1824,7 @@
|
||||
@@ -1695,6 +1825,7 @@
|
||||
@Override
|
||||
protected void removeAfterChangingDimensions() {
|
||||
super.removeAfterChangingDimensions();
|
||||
|
||||
Reference in New Issue
Block a user