[SPIGOT-2016] PlayerInventory.getHelItemSlot() Created: 21/Mar/16  Updated: 21/Mar/16  Resolved: 21/Mar/16

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

Type: Bug Priority: Minor
Reporter: ImAFlyingPancake Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: 1.9, inventory, slot


 Description   

PlayerInventory.getHelItemSlot() doesn't returns the real slot si it makes the method useless when you want to compare with InventoryClickEvent.getRawSlot() for example.

In fact PlayerInventory.getHelItemSlot() returns the slot beginning from the quickbar and not from the off hand slot. It will return 0 if the held item is the first of the quickbar, but this slot is actually the 36th.



 Comments   
Comment by ImAFlyingPancake [ 21/Mar/16 ]

Oh nice I didn't know about that! Thank you and sorry for the bothering

Comment by Black Hole [ 21/Mar/16 ]

InventoryClickEvent.getRawSlot() makes no guarantee about slot numbers, just that they are unique within an InventoryView.
Have a look at the methods in InventoryView, like convertSlot().

Comment by ImAFlyingPancake [ 21/Mar/16 ]
@EventHandler
public void onClick(final InventoryClickEvent e) {
	e.getWhoClicked().sendMessage(String.valueOf(e.getRawSlot()));
}

Result : http://i.giphy.com/3osxYntlZ1BMk5FtPG.gif

Slot 0 is the crafting result slot.

Comment by Black Hole [ 21/Mar/16 ]

Actually, quick bar comes first, so the slot numbers are correct:
http://minecraft.gamepedia.com/Player.dat_format#Inventory_slot_numbers

Generated at Sat Dec 13 15:19:05 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.