Started by
alonso_allonsy
on
Topic category: Advanced modding
Hello, i am making a mod where when a player spawns a mob spawns with them and follows them around until the player dies, a sort of tamed companion. What i need help with is making it so that when the player dies so does that mob. It would also be good to know if it could work vice versa, so if the mob dies so does the player. I hope you can help. Thanks
you could easily do it when the pet dies if you stored the players name when taming it into the pets nbt then killing the player with that name via a kill command using the create text with block and the stored nbt. then for the other way around just do the another create text block with /kill @e[type=THEMOBSID,NBTTAG = get entity display name] you would have to go into the game and use the /data tag to find how the nbt you put in is actually stored then take that and try to figure out what syntax needs to be in what order than where the name would be where you put a get display name from. it would look something like this https://imgur.com/hAXMfoP make sure if you were to make the command that anything after the player's name was in the second box and make sure to not have any spaces at the end and the start of a text box unless the is supposed to be a space there in the command.
Thank you for this, it will help