SPIGOT-1608: Add a way to get the hand used in PlayerInteract*Events

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2016-03-04 15:24:51 +11:00
parent f668c8bc0e
commit a15545299d
10 changed files with 60 additions and 58 deletions

View File

@@ -37,7 +37,7 @@
public void a(BlockPosition blockposition, EnumDirection enumdirection) {
+ // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand());
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
+ if (event.isCancelled()) {
+ // Let the client know the block still exists
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
@@ -245,7 +245,7 @@
+ cancelledBlock = true;
+ }
+
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock);
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand);
+ firedInteract = true;
+ interactResult = event.useItemInHand() == Event.Result.DENY;
+