Note that
Item#onUpdate
is called when the item is in any of the player's three inventory sections (main, armour, off hand) and the slot argument will be relative to the start of that inventory; e.g. slot 0 could be slot 0 of the main inventory, slot 0 of the armour inventory or slot 0 of the off hand inventory.
You need to search through each inventory section and check if the
ItemStack
in the specified slot is the same as the
ItemStack
argument.
I use this method to perform an operation for the specified inventory sections in
Item#onUpdate
. You can see the usages here, here and here.