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