Started by
CoolCaution
on
Topic category: Help with Minecraft modding (Java Edition)
Ok so, Im making a entity (but technically multiple entities) that go through 3 stages of growth/ageing, (baby, teen, adult and possibly elder) I've made 3 different entities for the 3 different growth stages but one thing I really want to implement a way to name the baby once its born and have them keep that name til they grow old and die. is there any way to make an entity give/pass on a name to another entity when it despawns?
Edited by CoolCaution on Mon, 12/27/2021 - 21:08
Yes, it is possible to do so.
When you despawn the entity and spawn in the new entity do "if get nearest entity (name of the entity your spawning" inside of "is sub type of (name of your entity)". This is done to help prevent potential crashing if the game searches for an entity that doesn't exist. For the block radius, set 1 for all of the procedures
Inside of the if statement put another if statement and do "if get event/target entity display name doesn't equal (name of your entity)". Inside of this if statement do "set display name of (get nearest entity) to get event/target entity display name"
I'd you are still having issues or are struggling to understand what I said, feel free to ask any questions
Ok I kind of got confused at the beginning lol, the "if get nearest entity part if you could explain that different because i'm not sure what you mean.
So, grab an "is (event/target entity subtype of (name of entity)" procedure. Remove the "event/target entity" part and replace it with "get nearest entity (name of your entity) at x y z in radius 4"... Change the radius to be "1". Grab an "if" stament procedure and place this whole procedure inside of the "if" part of the if stament.
ok i put it together and which "event/target" slot do I put the 1st entity/entity despawning and the 2nd entity/entity being spawned?
Here is a screenshot of an example procedure. The "spawn at" procedure will likely look different than yours since I set it to "external inputs" so that it'd fit on the screen in a screenshot.
Replace the "Animal Entity" part with the name of the entity you're trying to spawn in. Replace the "NAME OF YOUR ENTITY" part with whatever you set your entity's name to in the "visual and sounds" section of your living entity.
If you didn't have the "if no get display name of event/target entity= NAME OF YOUR ENTITY" part, it'd set the name of the entity you're spawning in to be your original entity's name and you only want it to pass on the display name if the entity has been named with a nametag or such (I think?).
THANK YOU it was kinda hard to visualize what you were saying but now i understand, and yes, the entity/entities im making dont spawn with names but when they do spawn as baby's and you name one I just want them to keep the name after they grow up. Again THANK YOU!!!!
You're welcome! Also, I didn't clearly mention this, but the NAME OF YOUR ENTITY part, should be the name of your original entity, the one you're despawning. Since your entity technically does have a name (you set one when you create the entity, it just doesn't show like a nametag does), you don't want it to set the display name of your entity to something unless it isn't the default name (which means they used a nametag)
Ok so i'm not sure what you mean by "entity technically does have a name" can you use and example of one of your entities because i'm kinda stuck. The game crashes if the entity ages up without a name but with a name it works fine. I know you said to ut part of the procedure in the code to stop this from happening but I can get the procedure to work the way I want it to (ageing up the entity even if it doesn't have a name) but now I don't know how to age an entity without a name with out having to give it a name.
Nevermind I figured something else out thanks for the help :)
Sorry I didn't see your comment sooner. I'm glad you got it figured out!
Hey, how have you fixed the issue with entity aging up?