[SPIGOT-1607] getItemInHand() in BlockPlaceEvent always return the item in the main hand Created: 01/Mar/16  Updated: 06/Mar/16  Resolved: 01/Mar/16

Status: Closed
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: tur tur Assignee: Thinkofname
Resolution: Fixed Votes: 0
Labels: 1.9, blocks, bug, event, spigot
Environment:

Minecraft 1.9
Spigot version git-Spigot-1a196e1-7 6c0425 (MC: 1.9) (Implementing API version 1.9-R0.1-SNAPSHOT)
Windows 7 64Bit
Java 1.8.0_51



 Description   

When placing a block, the getItemInHand() method in BlockPlaceEvent event (not in the Player object) always return the item in the main hand, even if the block placed from the off-hand

Code:

@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
	System.out.println("onBlockPlace() called");
	System.out.println("onBlockPlace() item: " + e.getItemInHand().getType());
}

Result (Sand in off-hand, apple in main hand):
[23:11:41 INFO]: onBlockPlace() called
[23:11:41 INFO]: onBlockPlace() item: APPLE

Result 2 (Sand in off-hand, nothing in main hand):
[23:12:05 INFO]: onBlockPlace() called
[23:12:05 INFO]: onBlockPlace() item: AIR



 Comments   
Comment by tur tur [ 06/Mar/16 ]

I checked again now, seems to work in spigot too

Comment by tur tur [ 03/Mar/16 ]

@Thinkofname seems like the fix work in craftbukkit but not in spigot (latest version)

Comment by tur tur [ 03/Mar/16 ]

@Pr0totype2 but there is 2 hands, and i think the getItem() method should work

Comment by - Pr0totype2 [ 02/Mar/16 ]

Use #getInventory().getItemIn.....

Comment by Z750 [ 01/Mar/16 ]

This is a bug

Generated at Fri Mar 14 09:35:35 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.