Item with Health

Started by Angel_Knight on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item with Health

Hello,

 

i want to make an item that when you hold in your main hand gives you extra live, but when you scroll away and dont hold it in your hand or dont have it in your inventory, your life goes back to 10 hearts,

 

i tried a little bit and the only thing i am able to do is, that when u have it in your main hand you get more health, but the lifes stay that and dont go away anymore,

if anyone could help me i would appreciate it, thanks

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There's probably a couple of…
Tue, 10/25/2022 - 23:54

There's probably a couple of ways you could do this, but here's what I'd recommend:

  • Add an 'item in Inventory tick' procedure to the item.
  • For the procedure, if the player is holding the item in their main hand, (or off hand), have the item first check if the player has the Absorbtion effect.
    • If they don't have the item give them 1 second of Absorbtion of the desired level. (Absorbtion 1 will give you 2 extra hearts, Absorbtion 2 will give you 4 extra hearts, etc.) 
    • If they already have absorption, reset the Absorbtion timer to 1 second. (Or just set the timer to whatever the current time is, whatever works.)

There'll be a bit of a cooldown, (if they scroll away or drop the item, they'll still have absorption for a little bit before the effect wears off.) I'm also not quite sure how this would work if the player is injured; you might have to add something that checks the player's health and heals them instead of granting the effect if their health is below 20. (10 hearts.) 

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do i check for the…
Wed, 10/26/2022 - 00:03

How do i check for the effect?

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
and what if it should be…
Wed, 10/26/2022 - 00:13

and what if it should be like max health, like normal hearts and not absorbtion hearts?

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use health boost effect…
Wed, 10/26/2022 - 03:41

Use health boost effect instead

Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
jk
Wed, 10/26/2022 - 19:02

jk