Adding keybind when item is in a GUI

Started by God_Of_Wood on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Adding keybind when item is in a GUI

I need help finding a way to add a specific key bind when an item is inside a GUI. 

 

To give some context, in my mod, there's an item which opens a GUI into which other items can be placed. The idea was to make it so that every time an item is added into the GUI, it allows for different abilities to be unlocked, all of which would be bound to a specific key.

 

Is there any way to do this?

 

If not, would it be possible to have 2 key binds, one which activates the ability and another which changes the ability being used?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can't really make the…
Wed, 11/08/2023 - 20:13

You can't really make the existence of keybinds conditional; but you can add if conditions to them doing anything. (The keybinds would always exist, they would just only do something if your condition is met.) You would then want to use player-persistent variables to determine which abilities are unlocked, and another player-persistent variable to determine which ability is selected.