I want to build a zoo on Minecraft. So with pegs etc. But the animals disappear after a while. What can I do so that it doesn't happen and they stay there like when you lock up villagers, they always stay there. Please explained foolproof.
You have to name the animals. You can do that
Open your inventory
Search for "nameplate" and add it to your inventory
Looking for anvil and adding it to your inventory
Put the name tag in the anvil
At the top there should now be "Namesschild", just write the name of your choice there
Take the named nameplate and right-click the animals with it
Now you shouldn't despawn anymore
You name the animals with name tags
You program a plugin so that the animals do not despawn.
Option 1 is think easier when a single player plugin becomes difficult.
It all depends on your MC experience.
Use a name tag
Feed / tame the animals
Use the command / execute as @e [distance = .20] run data merge entity @s {PersistanceRequired: 1b} (All mobs within 20 blocks can no longer despawn)