@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemLeash.java
|
||||
+++ b/net/minecraft/world/item/ItemLeash.java
|
||||
@@ -15,6 +15,11 @@
|
||||
@@ -16,6 +16,11 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -31,7 +36,7 @@
|
||||
@@ -32,7 +37,7 @@
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
|
||||
if (!world.isClientSide && entityhuman != null) {
|
||||
@@ -21,45 +21,49 @@
|
||||
}
|
||||
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -40,7 +45,7 @@
|
||||
@@ -41,7 +46,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand
|
||||
EntityLeash entityleash = null;
|
||||
boolean flag = false;
|
||||
double d0 = 7.0D;
|
||||
@@ -56,9 +61,26 @@
|
||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||
+ 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, hand);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ entityleash.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityleash.playPlacementSound();
|
||||
}
|
||||
int i = blockposition.getX();
|
||||
@@ -54,12 +59,29 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ continue;
|
||||
EntityInsentient entityinsentient;
|
||||
|
||||
- for (Iterator iterator = list.iterator(); iterator.hasNext(); entityinsentient.setLeashedTo(entityleash, true)) {
|
||||
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) { // CraftBukkit - handle setLeashedTo at end of loop
|
||||
entityinsentient = (EntityInsentient) iterator.next();
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||
+ 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, hand);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ entityleash.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityinsentient.setLeashedTo(entityleash, true);
|
||||
flag = true;
|
||||
entityleash.playPlacementSound();
|
||||
}
|
||||
@@ -70,4 +92,10 @@
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ entityinsentient.setLeashedTo(entityleash, true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return flag ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
if (!list.isEmpty()) {
|
||||
@@ -69,4 +91,10 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
||||
Reference in New Issue
Block a user