#1107: Add getHand() to all relevant events
By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -1,21 +1,43 @@
|
||||
--- a/net/minecraft/world/item/ItemLeash.java
|
||||
+++ b/net/minecraft/world/item/ItemLeash.java
|
||||
@@ -15,6 +15,8 @@
|
||||
@@ -15,6 +15,11 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -57,9 +59,25 @@
|
||||
@@ -31,7 +36,7 @@
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
|
||||
if (!world.isClientSide && entityhuman != null) {
|
||||
- bindPlayerMobs(entityhuman, world, blockposition);
|
||||
+ bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand
|
||||
}
|
||||
|
||||
world.gameEvent(GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman));
|
||||
@@ -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;
|
||||
@@ -57,9 +62,26 @@
|
||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // 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);
|
||||
+ 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()) {
|
||||
@@ -27,7 +49,7 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -35,3 +57,14 @@
|
||||
entityinsentient.setLeashedTo(entityleash, true);
|
||||
flag = true;
|
||||
}
|
||||
@@ -67,4 +89,10 @@
|
||||
|
||||
return flag ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
+ return bindPlayerMobs(entityhuman, world, blockposition, net.minecraft.world.EnumHand.MAIN_HAND);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user