mojira.dev
MCPE-55270

Phantoms are not despawning in Peaceful Difficulty

Since the last update 1.13.0 phantoms have been occasionally spawning when the game is set to peaceful difficulty.  They remain passive until the game is set to a difficulty other than peaceful. 

Technical details from [~Auldrick]:

It used to be that monsters in chunks outside of ticked areas were not deleted when you set the difficulty to peaceful, so if you visited an area during the night with normal difficulty, left while it was still dark, and then switched to peaceful and went back there, one of two things would happen:

  • If it was daylight when you went back, the hostile mobs would still be there and the undead ones would catch fire and burn to death.

  • If it was night when you went back, the hostile mobs would still be there and would target you if you were close enough.

Mojang recently made changes that included causing some mobs to despawn more frequently. Perhaps at that time, they arranged for hostile mobs outside the player's ticking area to despawn as well, because the above scenario no longer occurs. Instead, if you return to the area during the day, the hostile mobs are simply gone. Except for phantoms. Any phantoms you left behind in the darkness will still be there when you return, even if the difficulty is set to peaceful.

Steps to reproduce:

  1. Select a world you haven't slept in for several days, so that phantoms will spawn in it.

  2. In creative mode with difficulty set to normal, find a good sized plain (for visibility's sake).

  3. Set the time to night. Watch for a bunch of monsters to spawn, including phantoms.

  4. Fly (or teleport) at least 200 blocks away.

  5. Set the time to noon. Set the difficulty to peaceful.

  6. Fly or teleport back to the plain.

Expected results:
All the monsters are gone.

Actual results:
All the monsters except phantoms are gone. The phantoms are there and start burning as soon as you get within ticking range.

Linked issues

Attachments

Comments 19

Are you sure you mean phantoms and not ghasts? We've had several reports of ghasts spawning on peaceful and I can reproduce that, but I can't get the same thing to occur with phantoms.

I was in a swamp biome on the overworld when it happened so they were definitely phantoms and not ghasts.

Well, there is a way it could happen if the world hasn't always been in peaceful and nobody goes near this swamp very often. Let me describe a scenario: The phantoms may have spawned a long time ago when you were near the swamp and the difficulty was set to normal or hard. Instead of sleeping or trying to kill them, you decided to fend them off and/or try to hide from them as you made your way back to base, because you were heading for home at the time anyway. You managed to lose them and left them behind before dawn. The encounter wasn't a big deal, so you forget all about it.

The situation at this point is that you're now too far from the swamp for it to be in your ticking area, so the swamp chunks are no longer being ticked. (If you're more familiar with Java Edition, you can think of this as equivalent to saying "the swamp chunks are unloaded".) The phantoms are still in those chunks, suspended now so there's no day or night for them and the phantoms don't burn up. For as long as nobody gets close enough to wake up those chunks, they'll just stay that way, because nothing can happen in an unticked chunk.

Now here's the kicker and the thing you probably didn't know: When you switch the difficulty to peaceful, the game disables spawning new hostile mobs and deletes the hostile mobs that were already spawned, but only those in your ticking area. The reason is that to delete the mobs, it has to erase them from the chunk they're in. But a world could potentially have tens of thousands or even millions of chunks. There isn't time to go through every one of them looking for hostile mobs to delete. So it only deletes the hostile mobs in your ticking area, the chunks close to you. To sum up, putting the game into peaceful will normally leave dozens of hostile mobs in your world...but only in unticked chunks.

So suppose you're in peaceful now and you happen to head back toward the swamp. As soon as you get within range, those chunks wake up and become part of the world again, and so do the phantoms that you left trapped in them. Of course, if it happens to be day at the time, the phantoms will immediately start to burn, but let's say you get there at night. The phantoms wake up and start screeching again, and because you forgot they were left over from before you assume that they've just spawned...in peaceful.

This is actually not as uncommon a scenario as it might seem. If you've ever left your base perimeter in the afternoon and taken a long walk, you've probably come across burning zombies and skeletons who are nowhere near any shelter from the sun. You might have mused about how they managed to spawn there in the middle of the day, because they're obviously too far from any shade to have walked where they are in the midday sun. The answer is that it's the same thing that happens with the phantoms, but without the difficulty setting to confuse the issue. Setting the difficulty to peaceful didn't really matter for either the phantoms or the zombies, because they weren't in your ticking area when you set it (and that's the only time it deletes mobs).

Of course, I just invented the details of this scenario for demonstration, as a way to illustrate what might have happened to you. You'll have to judge for yourself whether some version of this might explain your experience based on how far the swamp is from where you're normally working, how long it's been since you were there last, what your custom is with respect to the difficulty setting, etc.

Another moderator here, @unknown, challenged this explanation. In his experiments, hostile mobs appeared to despawn in peaceful even when they were far outside any player ticking areas. We studied the behavior, and it turns out he's right. I think this must be a recent change, perhaps something they did at the same time they introduced mob despawning on the surface at a certain distance from the player.

However, it turns out that this despawning doesn't apply to phantoms. When I went back in peaceful daytime to a place where they had spawned in the dark and that I left while it was still dark, as soon as I got close enough to tick them the phantoms started burning. I had left other monsters in the area too, but they were simply gone. So I think that when Mojang changed how peaceful works, they probably overlooked despawning phantoms in distant chunks. This means you're probably right, this is a bug, and I will confirm it now.

Both phantoms and ghasts don't despawn for me either on single player and dedicated server

9 more comments

@unknown: I'm sure it;s happening for you, because you've clearly been diligently exploring the problem. Unfortunately, the devs have to be able to reproduce the problem before they can fix it. (Otherwise how would they know when they've succeeded?)

I created a world in 1.17.10 specifically to test this, but for me the phantoms despawned the instant I switched to Peaceful. So there is something special and we have to identify what it is before progress can be made on fixing it.

Could it be a question of how far the phantoms are above you? Phantoms always spawn and generally hover near a fixed Y level, so if you were standing on terrain lower than usual (say, below Y=64) that might be the X factor. Or, could they actually be hovering above somebody else, so that they're not within your player ticking area? Again, distance would be the X factor. I'm focusing on distance because we know something like this is possible when mobs are near the edge of your ticking area. But it could be something else entirely, I'm just guessing.

Despite what you think, a video or screenshot probably would reveal something beyond the description you've given. People always leave out the majority of factual detail when describing something, otherwise just describing what you had for breakfast would bore your listener to tears. It's so automatic to do this that we don't even realize how much we're omitting. But when it comes to something as technical as identifying a bug, those details are often crucial.

Generally, the trick in situations like this is to identify a reliable case that reproduces the bug, and then either provide us a copy of the world with any steps necessary to make it happen, or start changing one thing about it at a time until it doesn't happen again. Then you know the thing you changed is part of that something "special" that triggers the bug. So definitely, see if you can get it to happen again, preferably in a single player world that's small enough to attach (<10 MB).

Hi ! Sorry about the delayed reply.

I agree that this seems to be an iffy/hard to pin down bug - I'm quite clueless myself actually - and i understand that just a mention of it occurring, without much info or speculation as to reproducing it isn't too useful for the devs. This hadn't happened ever before for me (I keep switching difficulty relatively often in a few worlds). I found out about this ticket shortly afterwards by asking some others, and seeing that it had been temporarily closed, I thought of adding a comment.

I tried reproducing the bug again a couple of times (in newly created worlds, as well as the existing ones), to no avail. I've attached a short clip "(not a successful demo).mp4" to the ticket, recorded in a copy of the same world (from a backup closest to the time it had happened, although i did spend a few days doing other things without sleeping to get phantoms to spawn). I perform the same actions, in the same place as I did when it originally occurred - to give a visual idea of what it looked like (except for the fact that phantoms would have remained ultimately -they didnt).

Some minor differences from the video are (just in case there are some vague connections) -

  • When it originally happened, I wasn't wearing armour with thorns on it (if the damage taken by phantoms counts as some sort of "interaction"), so they took no damage then.

  • There also were a few other monsters targeting/following me originally - I'd changed it from peaceful to hard to lead a zombie into my villager trading hall, so that i could infect & cure them to get discounts. They disappeared when i changed back to peaceful.

  • There had also been some other very strange glitches (forgot to mention this in the first comment !) before, where it was raining/snowing non-stop for several days in a row (even after I slept at nights), and in-between the rain stopped (no particles/fog) for a while but the sky remained dark as earlier, before continuing again. I saved & quit, re-logged in when it went back to normal, and a few in-game days later was when the phantom incident occurred.

I was the only player online at the time, so only the 8-chunk sim distance chunks were ticking (and the phantoms were relatively close by, like in the video). The height is also around y=72.

If i find it happens again, I'll definitely provide an export of the world.

I can still reproduce this in the same ways described in my earlier comment. When using the test world, be sure to name tag the phantom before moving away from it.

Basically the issue is this: phantoms only despawn in peaceful if they are loaded (in system RAM) at the time the difficulty is switched to peaceful. So if you switch difficulty while the world is closed or while in a different dimension, or after loading the phantom's dimension but before loading the mob itself, then it does not despawn.

The easiest way to see the bug is to

  1. spawn a zombie and a phantom next to each other,

  2. save & quit,

  3. change to peaceful in world settings, then

  4. reload the world.

The zombie will be gone but the phantom will still be there.

Please confirm if this is still an issue for you?

I did still reproduce in 1.21.60.28 Preview.

Mikaela Kennedy

(Unassigned)

274828

Confirmed

Multiple

1.17.11 Hotfix, 1.16.100.54 Beta, 1.16.0.66 Beta, 1.13.3, 1.13.1, ..., 1.14.30 Hotfix, 1.14.60 Hotfix, 1.16.20, 1.16.201 Hotfix, 1.18.1 Hotfix

Retrieved