mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 16:12:18 -07:00
Pass hand to entity unleash event
This commit is contained in:
@@ -1037,6 +1037,15 @@
|
|||||||
leashable1.setLeashedTo(this, true);
|
leashable1.setLeashedTo(this, true);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
@@ -2103,7 +_,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemInHand = player.getItemInHand(hand);
|
||||||
|
- if (itemInHand.is(Items.SHEARS) && this.shearOffAllLeashConnections(player)) {
|
||||||
|
+ if (itemInHand.is(Items.SHEARS) && this.shearOffAllLeashConnections(player, hand)) { // Paper - PlayerUnleashEntityEvent - pass used hand
|
||||||
|
itemInHand.hurtAndBreak(1, player, hand);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else if (this instanceof Mob mob
|
||||||
@@ -2116,11 +_,14 @@
|
@@ -2116,11 +_,14 @@
|
||||||
if (this.isAlive() && this instanceof Leashable leashable2) {
|
if (this.isAlive() && this instanceof Leashable leashable2) {
|
||||||
if (leashable2.getLeashHolder() == player) {
|
if (leashable2.getLeashHolder() == player) {
|
||||||
|
@@ -1497,7 +1497,13 @@ public class CraftEventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handlePlayerUnleashEntityEvent(Entity entity, net.minecraft.world.entity.player.@Nullable Player player, @Nullable InteractionHand hand, boolean dropLeash) {
|
public static boolean handlePlayerUnleashEntityEvent(Entity entity, net.minecraft.world.entity.player.@Nullable Player player, @Nullable InteractionHand hand, boolean dropLeash) {
|
||||||
if (player == null || hand == null) return true;
|
if (player == null || hand == null) {
|
||||||
|
if (entity instanceof final Leashable leashable) {
|
||||||
|
if (dropLeash) leashable.dropLeash();
|
||||||
|
else leashable.removeLeash();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(hand), dropLeash);
|
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(hand), dropLeash);
|
||||||
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
Reference in New Issue
Block a user