Topic category: Help with Minecraft modding (Java Edition)
I have a huge problem: i want to run a procedure when the player left clicks, but there is no keybinding for that. I want also that the procedure is runnable only if the player has no item in main hand. I'm desperate because to detect the left click i have to use global triggers like "player uses item" or "player left click on block" or "entity attaked" (setting the sourceentity logic nbt tag "leftclicked" to true), BUT i don't want items in hand and i don't want to hit an entity to trigger the procedure ("player left click on block" trigger is useless to me).
Other details to what i want to do: i want that when a player has a custom effect, has no items in main hand, and left clicks, even if has clicked in air, it run a procedure that shoots a fireball, whatever the player has clicked.
I searched everywhere but i didn't found the answer. I hope someone can answer.
Sorry for the bad english.
I recommend using a custom keybind for this. Add a new keybinding, set it to left click by default, and then add your trigger for whenever that button is clicked. You'll want to make sure you check that the player has an empty itemstack in their main hand, and probably check that they don't have any menus open, or it will literally trigger whenever the left-click button is pushed.
I created the keybind but i can't set it to left click, or i don't know how to do. In the given list of keys there aren't left\right click.
If you use fabric with fabric essentials, there is a new global trigger for when a player left clicks
Thank you very much for your tip, but i use forge. I will consider the option of rebuild all the mod in fabric version, but i prefer continuing use forge version.