How do I make an item that increases my health whenever used?

Started by Cleff. on

Topic category: Help with modding (Java Edition)

Last seen on 00:30, 7. Feb 2022
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make an item that increases my health whenever used?

Hey, I need some help making a mod for my friend. I'm trying to create an item that when used increases your max HP by 2 (1 Heart.) I already have an attribute command set up that increases your HP from (10) (13) (Which is 10 to 11 hearts) and am confused about how I could increased this so the more of the item used the more health you are given. Thank you!

attribute @p minecraft:generic.max_health base set 13

Last seen on 03:40, 29. Jan 2023
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could try making a new…
Sun, 01/23/2022 - 08:38

You could try making a new variable called "Max Health" (or anything you want, as long as you remember what it means), set to:

Variable type: number

Variable scope: player_persistent

 

Then set the initial value to 10, and make a procedure so that whenever you use the item, it increases the variable by however much health you want it to add (so +2 for an extra heart).

 

Lastly, make a procedure that sets your max health to the number that the variable is set to.

I'm not 100% sure if that will work, but feel free to try it and ask me if it doesn't!

Last seen on 00:30, 7. Feb 2022
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh my gosh thank you so much…
Sun, 01/23/2022 - 08:55

Oh my gosh thank you so much for helping! I'm fairly new to modding and this is a pretty big thing for me. I haven't used variables too much but I've figured some things out. How exactly to I change or add numbers to the variable through a procedure? Thank you!

Last seen on 00:30, 7. Feb 2022
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also, I would just like to…
Sun, 01/23/2022 - 09:05

Also, I would just like to add about how I would convert the variable to the maxhealth of the player. Which block would I use?

Last seen on 17:02, 6. Jun 2023
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You have to make a second…
Mon, 01/24/2022 - 21:09

You have to make a second variable that holds the words of your command

Last seen on 00:30, 7. Feb 2022
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you!
Tue, 01/25/2022 - 03:39

Thank you!