How to fire a projectile when left click is pressed with procedures?

Started by Spyjetray on

Topic category: Help with modding (Java Edition)

Last seen on 14:17, 4. Dec 2020
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to fire a projectile when left click is pressed with procedures?

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.

Last seen on 00:30, 24. Aug 2023
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can make this work with…
Sun, 08/30/2020 - 19:12

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.

Last seen on 14:17, 4. Dec 2020
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What I meant was if you were…
Sun, 08/30/2020 - 20:05

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?

Last seen on 19:13, 24. May 2021
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, with very simple custom…
Sun, 08/30/2020 - 20:50

Yes, with very simple custom code, using keypress events. I suggest looking it up, tutorials would have more knowledge than I.

Last seen on 00:30, 24. Aug 2023
Joined May 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've tried using custom…
Wed, 09/02/2020 - 01:12

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.

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
use custom code snippets…
Wed, 09/02/2020 - 13:28

use custom code snippets. check for the living entity boolean field "isSwingInProgress", if true, shoot projectile.

Last seen on 16:31, 21. Aug 2021
Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
help me men, i don't know…
Thu, 07/29/2021 - 00:58

help me men, i don't know how can I make a trigger what work with the left click in ranged items.