How to get ItemInHand data?

Now I understand that to get itemInHand you use

Itemstack Item = player.getItemInHand

and ID is

Item.getItem().getName().equals("minecraft:stick")

(I think)

What I’m trying to do is get item name or lore data, I’ve tried searching but I’m not to sure.

That type of data is part of the Data API. To read more on it, visit here, here, and here.

2 Likes

For the ID check, try using Item.getItem() == ItemTypes.stick. The ItemTypes class contains references to all ItemTypes available in vanilla.

While item.getItem() == ItemTypes.STICK might work, it is preferable to use item.getItem().equals(ItemTypes.STICK)

1 Like