Detecting selected hotbar slot

Started by Coolmanz7 on

Topic category: Help with modding (Java Edition)

Last seen on 02:49, 12. Apr 2024
Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Detecting selected hotbar slot

I was wondering on how to detect which of the 9 hotbar slots the player is currently on. I want to make each hotbar slot have its own unique ability. I don't think there is a specific block for this in any of the procedures tabs.

Last seen on 03:14, 3. Jun 2023
Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here is how I detected theā€¦
Mon, 04/03/2023 - 18:18

Here is how I detected the slot ID of the item in your main Hand.

https://imgur.com/5ufv8C2

I created a temporary item to replace with the the item in your main hand. Then I searched the inventory (slots 0 - 9) for said temporary item. When it finds that item, it exits the loop at give you the slot ID number of the item in your main Hand (variable: num).

You can return the item to your main Hand if needed, as the item info was stored in the inHand variable.

Last seen on 02:49, 12. Apr 2024
Joined Aug 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you for helping me!
Sun, 04/09/2023 - 16:07

Thank you for helping me!