[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. |
| 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: |