Item that triggers once

Started by YuriRusher98 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item that triggers once
Wed, 09/14/2022 - 20:20 (edited)

I'm trying to make an item that increases your health while in the inventory and undo the health increase when taken out, but it loops constantly and keeps increasing health by tick. 

This is what I was trying when I realized it didnt make sense.

 

https://postimg.cc/yghCyBnc

This is the procedure.

Edited by YuriRusher98 on Wed, 09/14/2022 - 20:20
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
create a global logic…
Wed, 09/14/2022 - 22:49

create a global logic variable of player lifetime

and a global procedure on player tick

IF the global is FALSE

    check if player has item

    if so set the variable to true. and execute your health command

ELSE if in true

and DOESN'T

       have the item on inventory. execute back the command to decrease hp 

       and set to false the var

 

Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you pass to 1.17+ instead…
Wed, 09/14/2022 - 22:50

if you pass to 1.17+ instead of your entire procedure for the hp just execute

attribute @s minecraft:generic.max_health base set (max hp + X)

and. 0.5 in max health is less than half heart. a full heart is 2 hp