Fix passive mobs despawning #1458

Merged
kay27 merged 1 commits from slaesvuo/MineClone2:master into master 2021-04-04 12:18:45 +02:00
Contributor

According to the wiki most passive mobs do not despawn. The ones that do have already been explicity marked as despawning.

https://minecraft.fandom.com/wiki/Spawn#Despawning
https://minecraft.fandom.com/wiki/Mob#Despawning

According to the wiki most passive mobs do not despawn. The ones that do have already been explicity marked as despawning. <https://minecraft.fandom.com/wiki/Spawn#Despawning> <https://minecraft.fandom.com/wiki/Mob#Despawning>
slaesvuo added 1 commit 2021-04-04 08:19:29 +02:00
4a085c9526 Fix passive mobs despawning
According to the wiki most passive mobs do not despawn. The ones that do
have already been explicity marked as despawning.

<https://minecraft.fandom.com/wiki/Spawn#Despawning>
<https://minecraft.fandom.com/wiki/Mob#Despawning>
Contributor

Hi, thanks for making PR.
Can you please briefly explain what it fixes, how mob demography changes, why not to use can_despawn = false (already there by design), especially doesn't it mean you admit random despawning of mobs_mc:enderdragon?
I'm still not pretty familiar with mob part, that's why I'm asking this, please excuse me my stupidity, and if some colleagues orientate better - they still free to accept PR instantly.

Hi, thanks for making PR. Can you please briefly explain what it fixes, how mob demography changes, why not to use ```can_despawn = false``` (already there by design), especially doesn't it mean you admit random despawning of ```mobs_mc:enderdragon```? I'm still not pretty familiar with mob part, that's why I'm asking this, please excuse me my stupidity, and if some colleagues orientate better - they still free to accept PR instantly.
Author
Contributor

I didn't set can_despawn = false for every passive mob, because in general they should not be able to despawn (only bats, ocelots and wolves can).

mobs_mc:enderdragon has can_despawn = falseset explicitly so it cannot despawn. The dragon is also a hostile mob so this wouldn't affected it anyway.

The problem fixed is that passive animals can randomly dissappear which is very problematic if a player has spent time gathering them into a pen and then they despawn, leaving the player wondering what happened to their animals.

I didn't set `can_despawn = false` for every passive mob, because in general they should not be able to despawn (only bats, ocelots and wolves can). `mobs_mc:enderdragon` has `can_despawn = false`set explicitly so it cannot despawn. The dragon is also a hostile mob so this wouldn't affected it anyway. The problem fixed is that passive animals can randomly dissappear which is very problematic if a player has spent time gathering them into a pen and then they despawn, leaving the player wondering what happened to their animals.

LGTM

LGTM
kay27 merged commit f54f4ebcf9 into master 2021-04-04 12:18:39 +02:00
Contributor

Wait, it's not that simple. :) Take a closer look at https://minecraft.fandom.com/wiki/Spawn#Despawning

Mobs should have a persistent attribute, which should default to false for most, even peaceful mobs, and false should be changed later, depending on certain factors.

All hostile mobs excluding shulkers, withers, elder guardians and ender dragons despawn unless they have been marked persistent.

So there we have 4 hostiles that should have persistent = true and all other hostiles persistent = false.

Non-hostile mobs that despawn include hostile wolves, ocelots, stray cats and wandering traders.

persistent = false here too, unless tamed (where applies), which makes them persistent = true.

Ambient mobs such as dolphins, fish, squids and bats despawn unless marked persistent.

These can't be tamed, so by default these should be persistent = false, but we will/should have fish in a bucket, and placing them outside of a bucket would mark them as persistent = true:

For fish, if they have been placed out of a fish bucket.

There's special cases, like this one:

Chickens that originally spawned as chicken jockeys follow zombie despawn rules, rather than chicken despawn rules.

And then there are are actions that can permanently set the persistent flag on, or only temporarily:

Mobs are persistent, meaning they do not despawn and do not count toward the mob cap, when... (read it in the wiki)

... like the Enderman's case that will only be temporarily be set as persistent if they have picked up a block.


So it's a bit more complicated, but ideally we should have these done properly someday. Regular mobs, even peaceful, would still despawn instantly if the player gets 128+ blocks apart from them, unless they've been fed by the player or marked as persistent by another action. I think even luring mobs with their favorite food marks them as persistent, because in Minecraft once you get them inside a pen (by luring them) they won't despawn, and their offsprings will inherit that attribute.

Wait, it's not that simple. :) Take a closer look at https://minecraft.fandom.com/wiki/Spawn#Despawning Mobs should have a `persistent` attribute, which should default to `false` for most, even peaceful mobs, and `false` should be changed later, depending on certain factors. > All hostile mobs excluding shulkers, withers, elder guardians and ender dragons despawn unless they have been marked persistent. So there we have 4 hostiles that should have `persistent = true` and all other hostiles `persistent = false`. > Non-hostile mobs that despawn include hostile wolves, ocelots, stray cats and wandering traders. `persistent = false` here too, unless tamed (where applies), which makes them `persistent = true`. > Ambient mobs such as dolphins, fish, squids and bats despawn unless marked persistent. These can't be tamed, so by default these should be `persistent = false`, but we will/should have fish in a bucket, and placing them outside of a bucket would mark them as `persistent = true`: > For fish, if they have been placed out of a fish bucket. There's special cases, like this one: > Chickens that originally spawned as chicken jockeys follow zombie despawn rules, rather than chicken despawn rules. And then there are are actions that can permanently set the persistent flag on, or only temporarily: > Mobs are persistent, meaning they do not despawn and do not count toward the mob cap, when... *(read it in the wiki)* ... like the Enderman's case that will only be temporarily be set as persistent if they have picked up a block. --- So it's a bit more complicated, but ideally we should have these done properly someday. Regular mobs, even peaceful, would still despawn instantly if the player gets 128+ blocks apart from them, unless they've been fed by the player or marked as persistent by another action. I think even luring mobs with their favorite food marks them as persistent, because in Minecraft once you get them inside a pen (by luring them) they won't despawn, and their offsprings will inherit that attribute.
First-time contributor

Regular mobs, even peaceful, would still despawn instantly if the player gets 128+ blocks apart from them, unless they've been fed by the player or marked as persistent by another action. I think even luring mobs with their favorite food marks them as persistent, because in Minecraft once you get them inside a pen (by luring them) they won't despawn, and their offsprings will inherit that attribute.

You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with.

>Regular mobs, even peaceful, would still despawn instantly if the player gets 128+ blocks apart from them, unless they've been fed by the player or marked as persistent by another action. I think even luring mobs with their favorite food marks them as persistent, because in Minecraft once you get them inside a pen (by luring them) they won't despawn, and their offsprings will inherit that attribute. You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with.
Contributor

You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with.

Nope, it's here:

Java Edition

Mobs other than fish despawn immediately if no player is within 128 blocks of it, while fish despawn if no player is within 64 blocks.

> You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with. Nope, it's here: > Java Edition > > Mobs other than fish despawn immediately if no player is within 128 blocks of it, while fish despawn if no player is within 64 blocks.
Author
Contributor

Based on my testing animals do not despawn even when the player is over 128 blocks away, at least not immediatly like hostile mobs, so either the wiki is wrong or despawning mechanics have changed after 1.12.2 (or there is a problem is in my test setup).

a video showing my test setup and results.

Based on my testing animals do not despawn even when the player is over 128 blocks away, at least not immediatly like hostile mobs, so either the wiki is wrong or despawning mechanics have changed after 1.12.2 (or there is a problem is in my test setup). [a video showing my test setup and results](https://laesvuori.fi/linked-pics/mob-despawning.webm).
Contributor

It might be that the game sets the passive mobs as persistent if they were (manually) spawn from eggs. I'm not sure if there's a way to check the persistent flag, but this would help explain why.

It might be that the game sets the passive mobs as persistent if they were (manually) spawn from eggs. I'm not sure if there's a way to check the persistent flag, but this would help explain why.
Author
Contributor

I spawned a pig with /summon pig ~ ~ ~ {PersistenceRequired:0} which should be correct according to the wiki and it still didn't despawn when I teleported 150 blocks away.

In 1.13 it would be easy to check wheter they are set as persistent with /data entity get but I don't know of any in-game way of checking it in 1.12.

I spawned a pig with `/summon pig ~ ~ ~ {PersistenceRequired:0}` which should be correct according to the wiki and it still didn't despawn when I teleported 150 blocks away. In 1.13 it would be easy to check wheter they are set as persistent with `/data entity get` but I don't know of any in-game way of checking it in 1.12.
First-time contributor

You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with.

Nope, it's here:

Java Edition

Mobs other than fish despawn immediately if no player is within 128 blocks of it, while fish despawn if no player is within 64 blocks.

I think the wiki's information here is misleadingly structured. The sentence "Non-hostile mobs that despawn include hostile wolves, ocelots, stray cats and wandering traders." is implying the intended meaning that normally, non-hostile mobs (pigs, cows, chickens, sheep, horses, donkeys, parrots, turtles, pandas, polar bears, bees, and villagers) don't despawn.

> > You're confusing Bedrock rules with Java rules. Under Java rules, passive mobs like sheep and cows never despawn, while under Bedrock rules, they can unless interacted with. > > Nope, it's here: > > Java Edition > > > > Mobs other than fish despawn immediately if no player is within 128 blocks of it, while fish despawn if no player is within 64 blocks. I think the wiki's information here is misleadingly structured. The sentence "Non-hostile mobs that despawn include hostile wolves, ocelots, stray cats and wandering traders." is implying the intended meaning that normally, non-hostile mobs (pigs, cows, chickens, sheep, horses, donkeys, parrots, turtles, pandas, polar bears, bees, and villagers) don't despawn.
Contributor

The wiki is unfortunately ambiguous with those two statements. As it is, we can't be sure what they meant because we can just as well expand "Mobs other than fish" to all the other mobs, including non-hostiles.

This sentence vaguely supports my earlier assumption:

Mobs are persistent, meaning they do not despawn and do not count toward the mob cap, when...

... followed by a list of conditions, implying that otherwise they're not persistent. I wish that wiki would be more clear.

The wiki is unfortunately ambiguous with those two statements. As it is, we can't be sure what they meant because we can just as well expand "Mobs other than fish" to all the other mobs, including non-hostiles. This sentence vaguely supports my earlier assumption: > Mobs are persistent, meaning they do not despawn and do not count toward the mob cap, when... ... followed by a list of conditions, implying that otherwise they're not persistent. I wish that wiki would be more clear.
First-time contributor

To be quite frank, the wiki is poorly written and assumes its readers play regularly (very bad assumption in writing in general); it thus assumes them familiar with things like having penned in some animals or discovered some horses, and not seen them go away after traveling around.
Load up Minecraft 1.11 and find a group of pigs/sheep/cows/horses/chickens/etc., teleport a few hundred blocks upward (keeps chunks loaded but ensures you're at a sufficient distance), then return to observe whether they despawn. You should see them still there. Do the same for 1.16.5 and if nothing's changed, get on the wiki and edit it.

To be quite frank, the wiki is poorly written and assumes its readers play regularly (very bad assumption in writing in general); it thus assumes them familiar with things like having penned in some animals or discovered some horses, and not seen them go away after traveling around. Load up Minecraft 1.11 and find a group of pigs/sheep/cows/horses/chickens/etc., teleport a few hundred blocks upward (keeps chunks loaded but ensures you're at a sufficient distance), then return to observe whether they despawn. You should see them still there. Do the same for 1.16.5 and if nothing's changed, get on the wiki and edit it.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#1458
No description provided.