2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/item/ItemLeash.java
|
|
|
|
+++ b/net/minecraft/world/item/ItemLeash.java
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -13,6 +13,8 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class ItemLeash extends Item {
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
public ItemLeash(Item.Info item_info) {
|
2022-02-28 16:00:00 +01:00
|
|
|
@@ -54,9 +56,25 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
if (entityinsentient.getLeashHolder() == entityhuman) {
|
2014-11-25 22:32:16 +01:00
|
|
|
if (entityleash == null) {
|
2021-11-21 23:00:00 +01:00
|
|
|
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ // CraftBukkit start - fire HangingPlaceEvent
|
|
|
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
2021-11-21 23:00:00 +01:00
|
|
|
+ entityleash.discard();
|
2019-12-10 23:00:00 +01:00
|
|
|
+ return EnumInteractionResult.PASS;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
entityleash.playPlacementSound();
|
2021-06-11 07:00:00 +02:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) {
|
|
|
|
+ continue;
|
2021-06-11 07:00:00 +02:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
+
|
2021-11-21 23:00:00 +01:00
|
|
|
entityinsentient.setLeashedTo(entityleash, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
flag = true;
|
2021-06-11 07:00:00 +02:00
|
|
|
}
|