Started by
bob_bacon
on
Topic category: Help with Minecraft modding (Java Edition)
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?
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.
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.
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.