3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/ItemHanging.patch

33 Zeilen
1.5 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemHanging.java
+++ b/net/minecraft/server/ItemHanging.java
2019-04-23 04:00:00 +02:00
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.hanging.HangingPlaceEvent;
+// CraftBukkit end
2019-04-23 04:00:00 +02:00
+
public class ItemHanging extends Item {
2019-04-23 04:00:00 +02:00
private final EntityTypes<? extends EntityHanging> a;
@@ -41,6 +46,18 @@
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
2018-07-15 02:00:00 +02:00
+ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().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);
+
2019-04-23 04:00:00 +02:00
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace);
2016-02-29 22:32:46 +01:00
+ world.getServer().getPluginManager().callEvent(event);
+
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
((EntityHanging) object).playPlaceSound();
world.addEntity((Entity) object);
2016-02-29 22:32:46 +01:00
}