mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
22 lines
1.5 KiB
Diff
22 lines
1.5 KiB
Diff
--- a/net/minecraft/world/item/HangingEntityItem.java
|
|
+++ b/net/minecraft/world/item/HangingEntityItem.java
|
|
@@ -66,6 +_,19 @@
|
|
|
|
if (hangingEntity.survives()) {
|
|
if (!level.isClientSide) {
|
|
+ // CraftBukkit start - fire HangingPlaceEvent
|
|
+ org.bukkit.entity.Player who = player == null ? null : (org.bukkit.entity.Player) player.getBukkitEntity();
|
|
+ org.bukkit.block.Block blockClicked = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos);
|
|
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace);
|
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand());
|
|
+
|
|
+ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) hangingEntity.getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemInHand));
|
|
+ level.getCraftServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return InteractionResult.FAIL;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
hangingEntity.playPlacementSound();
|
|
level.gameEvent(player, GameEvent.ENTITY_PLACE, hangingEntity.position());
|
|
level.addFreshEntity(hangingEntity);
|