Jump to content

How to change a players selected hotbar slot


fenris

Recommended Posts

I am trying to change the players currently selected hotbar slot. I found 

minecraft.thePlayer.inventory.changeCurrentItem(x)

however, this only selects the next or previous slot.

I am very new to this, sorry if I missed something obvious.

Thanks.

Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...

To do this in minecraft 1.16.5 it is very simple (note it should work for 16.4 as well, you might have to change some of the class names to match yours).

 

Minecraft.getInstance().player.inventory.currentItem = 8;

 

You can set 8 to whatever slot you want. For some reason minecraft adds 1 or takes away 1 with everything that has to do with inventorys so make sure you test it properly.

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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