craftbukkit/nms-patches/net/minecraft/world/item/ItemHanging.patch

34 lines
1.6 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemHanging.java
+++ b/net/minecraft/world/item/ItemHanging.java
@@ -13,6 +13,11 @@
import net.minecraft.world.item.context.ItemActionContext;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.hanging.HangingPlaceEvent;
+// CraftBukkit end
2019-04-23 12:00:00 +10:00
+
public class ItemHanging extends Item {
2019-04-23 12:00:00 +10:00
private final EntityTypes<? extends EntityHanging> a;
2021-03-16 09:00:00 +11:00
@@ -54,6 +59,18 @@
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
2018-07-15 10:00:00 +10:00
+ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().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);
+
2019-04-23 12:00:00 +10:00
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace);
2016-03-01 08:32:46 +11:00
+ world.getServer().getPluginManager().callEvent(event);
+
2016-03-01 08:32:46 +11:00
+ if (event.isCancelled()) {
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
2019-04-23 12:00:00 +10:00
((EntityHanging) object).playPlaceSound();
world.addEntity((Entity) object);
2016-03-01 08:32:46 +11:00
}