PaperMC/nms-patches/ItemHanging.patch

33 lines
1.4 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemHanging.java
+++ b/net/minecraft/server/ItemHanging.java
2016-05-10 13:47:39 +02:00
@@ -1,6 +1,10 @@
package net.minecraft.server;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.hanging.HangingPlaceEvent;
+// CraftBukkit end
2016-05-10 13:47:39 +02:00
public class ItemHanging extends Item {
2016-11-17 02:41:03 +01:00
@@ -20,6 +24,18 @@
2016-02-29 22:32:46 +01:00
if (entityhanging != null && entityhanging.survives()) {
if (!world.isClientSide) {
+ // CraftBukkit start - fire HangingPlaceEvent
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.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);
+
2016-02-29 22:32:46 +01:00
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
+ world.getServer().getPluginManager().callEvent(event);
+
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
2017-05-14 04:00:00 +02:00
entityhanging.p();
2016-02-29 22:32:46 +01:00
world.addEntity(entityhanging);
}