Jump to content

Get Selected Hotbar Slot


Recommended Posts

Hello all, so I am trying to get the hot bar slot selected by a player. I noticed there was an NBT Tag for this, but it is always returning 0.


Note: I am trying to get the slot number of the slot that the user currently has their hotbar on. Not the item in the slot. (Should return a number 0-8)

My code:



EntityPlayer player = e.entityPlayer;

NBTTagCompound nbt = player.getEntityData();

int selSlot = nbt.getInteger("SelectedItemSlot") + 1;




Thanks in advance.

Link to comment
Share on other sites

player.getEntityData is something else. It returns an NBTTagCompound to be used by mods to store extra data into an entity.


What you want is player.inventory.currentItem.


And aside from contrary belief, that IS the right variable. I have used it in a spell API...... So yes, it does work xD

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.


I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.