2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/item/ItemHanging.java
|
|
|
|
+++ b/net/minecraft/world/item/ItemHanging.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -23,6 +23,11 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.World;
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
|
|
|
+// CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public class ItemHanging extends Item {
|
|
|
|
|
2023-03-14 17:30:00 +01:00
|
|
|
private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -73,6 +78,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
if (((EntityHanging) object).survives()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!world.isClientSide) {
|
|
|
|
+ // CraftBukkit start - fire HangingPlaceEvent
|
2021-11-21 23:00:00 +01:00
|
|
|
+ Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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);
|
2022-10-02 00:07:14 +02:00
|
|
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(itemactioncontext.getHand());
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2022-10-02 00:07:14 +02:00
|
|
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return EnumInteractionResult.FAIL;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
((EntityHanging) object).playPlacementSound();
|
2024-04-23 17:15:00 +02:00
|
|
|
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, ((EntityHanging) object).position());
|
2021-11-21 23:00:00 +01:00
|
|
|
world.addFreshEntity((Entity) object);
|