2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/item/ItemHanging.java
|
|
|
|
+++ b/net/minecraft/world/item/ItemHanging.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -15,6 +15,11 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.level.World;
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
|
|
|
+// CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public class ItemHanging extends Item {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private final EntityTypes<? extends EntityHanging> type;
|
|
|
|
@@ -58,6 +63,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
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);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2021-07-21 01:32:54 +02:00
|
|
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
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();
|
2021-06-11 07:00:00 +02:00
|
|
|
world.a((Entity) entityhuman, GameEvent.ENTITY_PLACE, blockposition);
|
2019-04-23 04:00:00 +02:00
|
|
|
world.addEntity((Entity) object);
|