3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-17 20:10:10 +01:00
Paper/nms-patches/ItemHanging.patch
2018-07-15 10:00:00 +10:00

33 Zeilen
1.5 KiB
Diff

--- a/net/minecraft/server/ItemHanging.java
+++ b/net/minecraft/server/ItemHanging.java
@@ -1,6 +1,10 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.hanging.HangingPlaceEvent;
+// CraftBukkit end
public class ItemHanging extends Item {
@@ -25,6 +29,18 @@
if (entityhanging != null && entityhanging.survives()) {
if (!world.isClientSide) {
+ // CraftBukkit start - fire HangingPlaceEvent
+ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().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);
+
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
entityhanging.m();
world.addEntity(entityhanging);
}