Started by
Spyjetray
on
Topic category: Help with Minecraft modding (Java Edition)
Hi,
For my mod, I want it so whenever you press left click (swing hand), it fires a projectile.
Since this is something that should always be active when the right conditions are met, I want to use a procedure but I'm unsure how to do this?
Thanks.
You can make this work with Semi-automatic weapons, but you cannot get anything to continuously fire this way- at least, not to my knowledge.
There is a trigger in items (and maybe tools) to run a procedure when the player left-clicks (swings) the item. However, of course, this only applies to that one item and cannot be applied globally to all items.
if you're willing to get your hands dirty with custom code, I'm sure there are quite a few demonstrations of something like this working. Take The Crafting Dead, for example. It's super old but it used left and right-click to fire weapons.
What I meant was if you were wearing a specific piece of armour, you would be able to left click and it would fire a projectile regardless of whether you had an item in your hand or not. Is this possible?
Yes, with very simple custom code, using keypress events. I suggest looking it up, tutorials would have more knowledge than I.
I've tried using custom hotkeys and binding them to leftclick, however they are always overridden by the player's default leftclick action (mining). The procedure is never triggered.
Straight-up detecting if leftclick is being pressed might, in fact, be an option, but from my experience setting up a key listener is super annoying given MCreator's coding and file structure. You can still give it a go, I suppose. It can't hurt and I'm honestly pretty curious as well.
use custom code snippets. check for the living entity boolean field "isSwingInProgress", if true, shoot projectile.
help me men, i don't know how can I make a trigger what work with the left click in ranged items.