How to make an item that heals on pickup?

Started by Jacko22 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make an item that heals on pickup?

For those of you familiar with Terraria, I plan to add something akin to the small hearts that occasionally drop from enemies in that game. (if you are not familiar, they simply heal you a certain amount when picked up and then disappear) I'm having issues with my procedure, as events seem to not work half the time. I've put the procedure below, what I'm trying to do is first heal the player for 5 HP, and then remove the item from their inventory. I understand that there could then be issues if the player has a full inventory, if you have a possible fix for that it would be really appreciated.

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Why are you dealing -5…
Thu, 05/28/2026 - 20:15

Why are you dealing -5 damage. Why not just set current health to current health +5. Use the trigger in inventory and hand tick. Use the same procedure on both triggers. Same as above, just without the if. Set health +5, remove item.

Otherwise you can use on tick update, check in a cube of 2 or 3, idk how mcreator calculates that cube. But check for entity iterator = type dropped item. Then convert item entity, entity iterator to item, if it = your heart, despawn item and add health.

Otherwise you could also just make this "item" an entity, then use on player collides with entity trigger.

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is what I've got so far…
Fri, 05/29/2026 - 04:31

This is what I've got so far, I like your second idea. I'm a bit stuck tho.

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(No subject)
Fri, 05/29/2026 - 04:31

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here: You may need to put…
Fri, 05/29/2026 - 14:32

Here:

You may need to put the 'convert' /red part into its own if statement within the first as I don't know how the conversion is handled when the entity is not an item. Actually I would just do that anyway for assurance.

However this method is not guaranteed to work. I would still recommend making it an entity, like an xp orb.

You basically want to create an xp orb but instead it is a heart and gives health rather than xp, I would make it into an entity, pathfind to the nearest player if there is one in a radius of 8 or so. Scale the speed at which it moves to increase inversely to distance between the player and entity.

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I wonder why it only works…
Fri, 05/29/2026 - 21:00

I wonder why it only works when I drop the item. I would try the entity approach but it seems a little complicated 'cause I'm a very particular guy, so I'd want it to do all the same things as xp orbs. (ya know, be invulnerable, always face the player, and be a smaller, 2D model with a full-size texture.)

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Potentially it is only…
Fri, 05/29/2026 - 21:10

Potentially it is only recognised as a dropped item when actually dropped by a player. Does it not work when using the spawn dropped item procedure?

Model is a simple plane in blockbench, always facing the player is a simple equation, disable collisions and turn off all damage sources

Lmk if you want that and I’ll help

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This work? On player…
Fri, 05/29/2026 - 22:19

This work?

On player collision:

Model and mapping:

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
OMG why did it post two of…
Sat, 05/30/2026 - 03:05

OMG why did it post two of them???

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah but you turned on…
Sat, 05/30/2026 - 08:48

Yeah but you turned on entity model is transparent?

Anyway, to make it face the player use this:

The X pos and Z pos of entity iterator are just the x and z coordinates of your target, ie the player so I guess keep that the same and use an entity iterator to find nearby players, use a local logic too so that it doesn't flicker between every single player nearby. Then the normal x and z are the entities coordinates. Also atan2 is found in the + math block.

Pitch is different, potentially you need to override the bone/model folder with head movement animation for it to be able to be pitched. The pitch equation is maybe this:

Oh I just figured out why mine wasn't working, I put event/target entity for the y instead of entity iterator... it should be fine then

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is in the AI & Goals?
Sat, 05/30/2026 - 15:48

This is in the AI & Goals?

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No ai, on entity tick update…
Sat, 05/30/2026 - 20:01

No ai, on entity tick update, set rotation and pitch to that above. Put it inside an entity iterator, get entity iterator is type player AND local logic is false, if so set the rotation as above and set local logic to true.

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Alright so this?
Sun, 05/31/2026 - 18:19

Alright so this?

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yeah you need to put that…
Sun, 05/31/2026 - 18:37

Yeah you need to put that into an entity iterator though, get each entity at x y z in cube sized 32 or so. And add the local variable, something like TargetFound

Joined Dec 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The variable should be:…
Sun, 05/31/2026 - 19:05

The variable should be: Logic, GLOBAL_WORLD, and default to false?