Started by
Jacko22
on
Topic category: Help with Minecraft modding (Java Edition)
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.

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.
This is what I've got so far, I like your second idea. I'm a bit stuck tho.
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.
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.)
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
This work?
On player collision:
Model and mapping:
OMG why did it post two of them???
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
This is in the AI & Goals?
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.
Alright so this?
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
The variable should be: Logic, GLOBAL_WORLD, and default to false?