Trying to make an item heal a player a specific amount, but is just fill healing player

Started by Raven78 on Thu, 09/22/2022 - 03:52

Topic category: Help with modding (Java Edition)

Last seen on 02:15, 23. Sep 2022
Joined Sep 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Trying to make an item heal a player a specific amount, but is just fill healing player
Thu, 09/22/2022 - 03:52

So I'm trying to make an item heal the player 3 hearts. I have it working, but it full heals the player instead of just 3 hearts.

 Here is what I currently have:

https://imgur.com/a/WYWMZFI

 

Last seen on 01:56, 23. Nov 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I'm guessing the problem…
Fri, 10/21/2022 - 12:47

I'm guessing the problem here is that the right click trigger will trigger repeatedly if you're pushing right-click, even if you quickly discard the item. If you want to avoid this, either:

  • If the item is consumable, make sure to put a 'shrink itemstack' block before the healing trigger, so it won't continue to process the thing.
  • ...And if not, add some sort of cooldown, probably in the form of a player persistent variable that counts down every tick until it reaches zero and only allows the player to heal if it's at zero.