Fix passive mobs despawning #1458
No reviewers
Labels
No Label
#P1 CRITICAL
#P2: HIGH
#P3: elevated
#P4 priority: medium
#P6: low
#Review
annoying
API
bug
code quality
combat
commands
compatibility
configurability
contribution inside
controls
core feature
creative mode
delayed for engine release
documentation
duplicate
enhancement
environment
feature request
gameplay
graphics
ground content conflict
GUI/HUD
help wanted
incomplete feature
invalid / won't fix
items
looking for contributor
mapgen
meta
mineclone2+
Minecraft >= 1.13
Minecraft >= 1.17
missing feature
mobile
mobs
mod support
model needed
multiplayer
Needs adoption
needs discussion
needs engine change
needs more information
needs research
nodes
non-mob entities
performance
player
possible close
redstone
release notes
schematics
Skyblock
sounds
Testing / Retest
tools
translation
unconfirmed
mcl5
mcla
Media missing
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: VoxeLibre/VoxeLibre#1458
Loading…
Reference in New Issue
No description provided.
Delete Branch "slaesvuo/MineClone2:master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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 ofmobs_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.
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
hascan_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
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 tofalse
for most, even peaceful mobs, andfalse
should be changed later, depending on certain factors.So there we have 4 hostiles that should have
persistent = true
and all other hostilespersistent = false
.persistent = false
here too, unless tamed (where applies), which makes thempersistent = true
.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 aspersistent = true
:There's special cases, like this one:
And then there are are actions that can permanently set the persistent flag on, or only temporarily:
... 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.
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:
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.
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.
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 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.
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:
... followed by a list of conditions, implying that otherwise they're not persistent. I wish that wiki would be more clear.
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.