Procedure when right click on entity with cooldown

Started by bob_bacon on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Procedure when right click on entity with cooldown

So, I try to do a procedure, when player do a right click on entity, that deal damages to the target entity, but I want a cooldown otherwise it will be too powerful. I tried many things but none worked. Could someone help me please?

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you are planning to…
Tue, 07/25/2023 - 13:38

If you are planning to damage the enemy "with items", the following method would be suitable.

You can use the "cooldown<itemstack>for <20> tick for~~~" block in the item procedure tab.
Once this block is loaded, the <itemstack> will not be able to use *tick* and nothing will happen when you press right click.
This function is mainly used when a shield is hit by an axe.

(Also, 20ticks is 1 second, so for example 3 seconds is 60ticks)

If you are thinking of doing damage without using items.
Global variables (for each player) can also be used.

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
And how can I call the…
Tue, 07/25/2023 - 14:50

And how can I call the procedure to damage the enemy? I think there is no trigger on item "when right-clicked on entity", so I used a global trigger "a player right click on entity", but it does not care about the cooldown.

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It certainly was. My…
Wed, 07/26/2023 - 13:53

It certainly was. My apologies.

When you do it with global triggers, you may want to use global variables.Let's create a variable cooltime with (type:number) and also a global trigger (every tick).If the variable is greater than 0 in the every-tick procedure, reduce it by 1,Check to see if the variable is 0 in the attacking procedure.