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.
5 replies
Important Information
By using this site, you agree to our Terms of Use.