Command to Set Age for Name-Tagged Entities



  • My goal is to place a command block at spawn that checks the age of every name-tagged mob. If the age of the entity is less than zero, then the command block sets the age to -999999999.

    This should allow all animals, mobs, villagers, etc. which are name-tagged as babies to remain babies. All non-named entities should age normally.

    I only have a very basic understanding of minecraft coding, so even though I've been researching and testing for about three hours, I haven't gotten very far.

    I've tried naming an adult wolf Child and running this command to turn it into a child.

    execute as @e[name='Child'] run data merge entity @s {age:-9999999}
    

    Minecraft says that the date merge was successful, but I'm not seeing any change. The adult wolf remains an adult. (I've also tried to change a baby wolf into an adult using this same command without success.)

    Since I'm unable to complete the first step, I'm not certain what the final command should look like. Could someone please help me understand how to write the final command. As explained earlier, I want to identify all name-tagged entities with an age lower than zero and then set their age to -9999999.



  • The reason why the command in your original post is not working is because NBT tags are case-sensitive, and you did not respect the casing of the Age tag.

    You should have used {Age:-9999999}, not {age:-9999999}.

    This is a very simple issue that is easily preventable. In the future, always check the https://minecraft.fandom.com/wiki which displays a list of NBT tags with the correct capitalizations. You can also run /data get entity @e[type=wolf,limit=1,sort=nearest] to print off the data of the nearest entity (in this case, the nearest wolf).

    You can also experiment with command generators like https://mcstacker.net . If you do it this way, I would recommend using their /summon generator to try what happens when you set a mob's age, and copy and paste the NBT into your own command.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2