Started by DeRokerij on Wed, 01/11/2023 - 17:32
Topic category: Help with modding (Java Edition)
hi, I'm trying to make a mod with a mob that evolves over time, like once every minecraft day till its final evolution
so basically i want it to change to a different entity after a certain amount of ticks
any help you guys can offer with this would be great
Well this would be quite difficult and scuffed without custom code, but you would basically need to make a speperate mob for every stage and then despawn the old one and spawn the new one in the same place. (You could better hide this using particles maybe...)
thank you very much ill try that
anyone have any idea how to make an entity do something a specific amount of time after spawning?
You're going to want to use NBT tags for that. It sounds like what you're wanting to do is similar to how baby mobs grow up in vanilla, just with multiple stages. You'll have to have multiple individual mobs for that, like woodcraft mentioned.
"On initial entity spawn" you'll want a procedure that sets a custom number NBT tag of however long you want to wait before that entity evolves. The number you input is in ticks, with 20 ticks equal to a second.
Then on "On entity tick update" you'll want a procedure that gets that same tag and checks to see if it's equal to or below zero; if it isn't, set it to itself minus one. Once it does reach zero, you'll want to spawn the evolved form at the same x, y, z location, and preferably with the same 'direction yaw' and 'head pitch' as the pre-evolution as well. That way when it evolves, the new mob will be turned the same direction and its head will be looking the same direction as its predecessor. There are a bunch of other things you can try carrying over as well, like name, velocity, status effects, or damage taken, but that's up to you. After you spawn the new mob and carry over any values you want, just put in a despawn block to remove the old entity.
Also take into consideration if your entity evolves into something larger than it used to be. If it's too close to blocks when it evolves the evolution may spawn partially inside them and start suffocating. You may want to add a check to see if there's enough room around the entity before you spawn its evolved form.
If you haven't used NBT tags before they're actually very simple to use. In the text box you can put anything and that will be the name for your tag. The tag will be on the entity itself so you are able to use different procedures to check for a tag on an entity without the procedures needing to get variables from each other.