diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/item/ItemHanging.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/item/ItemHanging.patch | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/item/ItemHanging.patch b/patch-remap/og/net/minecraft/world/item/ItemHanging.patch new file mode 100644 index 0000000000..e259a2f2fb --- /dev/null +++ b/patch-remap/og/net/minecraft/world/item/ItemHanging.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/item/ItemHanging.java ++++ b/net/minecraft/world/item/ItemHanging.java +@@ -22,6 +22,11 @@ + import net.minecraft.world.level.World; + import net.minecraft.world.level.gameevent.GameEvent; + ++// CraftBukkit start ++import org.bukkit.entity.Player; ++import org.bukkit.event.hanging.HangingPlaceEvent; ++// CraftBukkit end ++ + public class ItemHanging extends Item { + + private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY); +@@ -72,6 +77,19 @@ + + if (((EntityHanging) object).survives()) { + if (!world.isClientSide) { ++ // CraftBukkit start - fire HangingPlaceEvent ++ Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity(); ++ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); ++ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(itemactioncontext.getHand()); ++ ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); ++ world.getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return EnumInteractionResult.FAIL; ++ } ++ // CraftBukkit end + ((EntityHanging) object).playPlacementSound(); + world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, ((EntityHanging) object).position()); + world.addFreshEntity((Entity) object); |