mojira.dev
MC-6431

Status effects are lost when returning to the overworld from the exit end portal

The bug

After killing the dragon and exiting the end portal, all status effects are removed.

How to reproduce

  1. Drink a potion/eat a golden apple

  2. Enter the end

  3. Kill the dragon

  4. Make sure you have time remaining on the effects

  5. Enter the exit portal and skip the credits
    ❌ "wake up" and all of the effects will be gone

Analysis

Code analysis by @unknown can be found in this comment.

Related issues

MC-11628 Potion effects are gone after entering the portal from killing the ender dragon at the end. MC-48699 Effects are gone after pelepoting from the End to the Overworld MC-78722 Potion Effects Disappearing MC-85917 After leaving The End the potion effects disappear MC-93030 Potion effects removed for no reason when going through portal MC-103241 The effect disappears. MC-108788 removeing potion effects MC-109000 lost effects when left end MC-120114 Going through the return portal removes the wither effect MC-130916 all status effects get cleared off when entering a exit portal in the end MC-147568 Potion effects gets removed after leaving The End dimension MC-148945 Potion effects are lost when exiting the end dimension MC-154578 "Hero of the Village" effect (and any effect that lasts forever) gets cleared when using the Exit Portal in The End. MC-156156 Regeneration and resistance stop working when switching between dimensions MC-156340 Potion effects instantly get disabled when exiting the main End Portal MC-162493 When you cross an end portal you lose the potion effect you have MC-164592 Potion effects are removed when entering end portal MC-166186 effects disappear after going through the end portal MC-174053 When I went ender, my effects dissappears MC-181632 portion effect disappearing MC-183730 All effects disappear when you jump into the exit portal MC-187767 The wither affect dissipars when going though the end portal. MC-188134 All the effects disappear when player returns to overworld from end MC-188971 You lose your effects while going through end portals (only those applied by commands) MC-190034 i lose effects when i go though the portal at the end MC-195424 DISREGARD RE-POST MISSED OC Potion Effects Gone After Leaving End (Bug?) 1.16.1 MC-199791 potion effects removed when going through end exit portal MC-205573 Player effects disappear after exiting the End MC-211956 When having Bad Omen effect and going through End Portal the effect clears MC-214845 Potion effects clear when leaving the end MC-220494 Potion effects clear when entering end portal MC-223986 After you enter the exit portal all your effects will be removed. MC-224604 Player loses status effects upon leaving the end MC-225530 After exiting end with effect on you, it have been cleared. MC-231050 When you give yourself health boost using /effect and get to the end and go back, the effect doesn't work but is still visible even with /effect clear MC-232959 Going though the end portal from the end to the overworld removes all status buffs MC-235108 Effects disappear when leave the end MC-238190 Exit portal removes all stat effects MC-253326 Player and mobs lost effects when they enter the end gate from the end to overworld MC-256992 Leaving End clears status effects MC-267206 Current Status Effects are cleared when going through the exit portal

Attachments

Comments

migrated
[media][media][media][media][media][media][media][media][media][media][media]
kumasasa

did you lose the effects or only the indication of the effects, see MC-3668 ?

Joseph Sirna`

I lost the indication of the effects and the effects themselves, I wasn't
moving nearly as fast.
Sounds like a duplicate of the bug mentioned by [OCD] Xavier Brown.

I'll look more closely for similar bugs next time.

Joseph Sirna

On Sun, Jan 6, 2013 at 12:04 PM, [Mod] Kumasasa (JIRA) <

08Juan80

I think this is not a duplicate of MC-3668, it mentions the effects are lost when entering through the portal spawned when killing the ender dragon at the end, the one I mentioned in the comments there, and Kumasasa told me it was another issue, that MC-3668 mentions about the effect animations. If I'm right, my issue (MC-11628) is a duplicate of this one, not of MC-3668.

08Juan80

If a mod can reopen this issue if I'm right with my comment above...

kumasasa

Reopened, since not a duplicate of (but related to) MC-3668

08Juan80

Added the 3 screenshots from MC-11628 plus 2 extra screenshots.
And this affects to Minecraft 1.5, and Minecraft 1.5.1
Added other 4 screenshots.

08Juan80

It was already reopened by Kumasasa @Tails.

qmagnet

Confirmed for 14w34b

Sonicwave

Confirmed for 1.8-pre2.

marcono1234

Confirmed for

  • 15w45a

marcono1234

Confirmed for

  • 15w51b

The reason for this is that the player respawns when he leaves the end through the portal. Therefor a new player instance is created and most data is copied, however for example active potion effects are not.

Ashley5478

Confirmed for 1.9 Full realese

TheGamingCat

confirmed for singleplayer

TheGamingCat

confirmed for 16w42a

ilmango

confirmed for 1.11

user-a4a49

Affects 1.13-pre6!

Kraif

Confirmed for 1.13.1.

Yanis48

Confirmed for 19w09a

KamiADN

Confirmed for 1.14.4

Jake Spencer

Occurs in 1.15, 1.15.1, 1.15.2 also

DatSansyBoi

Confirmed for 1.16 Pre-release 4

Bogdan Fediushin

Confirmed for 1.16 Pre-release 5

bugsbugsbugs

Confirmed for 1.16-rc1

Leo Xiang

Confirmed for 1.16.2

Mantegaloka

Confirmed for 1.16.3-rc1

Avoma

Can confirm 20w48a.

awesomemaker1123

confirmed 21w03a

Avoma

Can confirm in 21w05b.

Avoma

Can confirm in 21w07a.

Avoma

Can confirm in 21w15a.

Avoma

Can confirm in 21w17a.

Brevort

Can confirm in 21w18a.

Further, testing discovered MC-225055.

Ray

in 1.17 rc1

Avoma

Can confirm in 1.17.1.

Asher

Can confirm in 1.18 experimental snapshot 2

Avoma

@unknown, just to inform you, the 1.18 experimental snapshots are not supported on the bug tracker and this cannot be added as an affected version.

PR0CESS

Can confirm in 21w39a

Time for a code analysis. I made a working fix for the bug using this analysis, so I can say 100% that this is the issue. Fix

All Code Analysis is done in 1.17.1 using Mojang Mappings

Explanation of the problem:
When the player travels from the end to the overworld, it does not use the normal teleportation code or dimension change code. The reason for this is because the player might be watching the credits, so instead the player is removed from all worlds and awaits for the client to send a packet saying it's done to the server. It does this whether you are seeing the credits or not.
The issue is with the code that does this:
net/minecraft/server/level/ServerPlayer.java - restoreFrom(ServerPlayer, boolean)

public void restoreFrom(ServerPlayer oldPlayer, boolean alive) {
        ...
        if (alive) {
            this.getInventory().replaceWith(oldPlayer.getInventory());
            this.setHealth(oldPlayer.getHealth());
            this.foodData = oldPlayer.foodData;
            this.experienceLevel = oldPlayer.experienceLevel;
            this.totalExperience = oldPlayer.totalExperience;
            this.experienceProgress = oldPlayer.experienceProgress;
            this.setScore(oldPlayer.getScore());
            this.portalEntrancePos = oldPlayer.portalEntrancePos;
        } else if (this.level.getGameRules().getBoolean(RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
            this.getInventory().replaceWith(oldPlayer.getInventory());
            this.experienceLevel = oldPlayer.experienceLevel;
            this.totalExperience = oldPlayer.totalExperience;
            this.experienceProgress = oldPlayer.experienceProgress;
            this.setScore(oldPlayer.getScore());
        }
        ...
    }

When you respawn using the end portal, it uses this function. Nothing else in the game uses restoreFrom(player,true) where alive is set to true. So I am sure that everything that happens here, only happens for the end portal.
As you can see, everything inside of  if (alive) is what gets transferred from the old player instance in the end to the new player instance in the overworld. Although player status is kept in the variable: activeEffects which it inherits from LivingEntity.java
So the fix is simply to add:

this.activeEffects.putAll(oldPlayer.activeEffects);

After: this.portalEntrancePos = oldPlayer.portalEntrancePos;

Although that's not all, after doing my testing there was another issue that happened. The effects do not instantly appear once you travel through, it takes a while. This is because like most other data, you need to tell the client about these changes. Here's where you can do that:

net/minecraft/server/players/PlayerList.javarespawn(ServerPlayer, boolean)

public ServerPlayer respawn(ServerPlayer oldPlayer, boolean ) {
        ...
        ServerPlayer newPlayer = new ServerPlayer(this.server, newLevel, oldPlayer.getGameProfile());
        ...
        newPlayer.restoreFrom(oldPlayer, alive); //This is where the other function is called from
        ...
        LevelData levelData = lvt9.level.getLevelData();
        newPlayer.connection.send(new ClientboundRespawnPacket(...));
        newPlayer.connection.teleport(...);
        newPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(...));
        newPlayer.connection.send(new ClientboundChangeDifficultyPacket(...));
        newPlayer.connection.send(new ClientboundSetExperiencePacket(...));
        ...
        return newPlayer;
    }

What you can notice from this code is that there are multiple newPlayer.connection.send() happening here to update the client's information, what we need to do is add another one for the status effects.

Unfortunately, the status effects packet has not been modified in a long time and still only transfers one status effect at a time, unlike many of the newly upgraded packets which send all their info at once. So we need to send a packet for each effect until that is changed.
Here is how you would do this, you would simply add:

// player = newPlayer
player.activeEffects.forEach((_,eff) -> {
    player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), eff));
});

 Right after the last connection.send, which in this case is: newPlayer.connection.send(new ClientboundSetExperiencePacket(...));
That's it, now the effects are correctly transferred to the player when going from the overworld to the end & the client is updated so that they have the effects right before loading!

 

theGlotzerify

can confirm in 1.18.1

Avoma

Can confirm in 1.18.2.

clamlol

Affects 22w13a.

clamlol

Affects 22w18a.

Shourin

affects 1.19 pre 3

MacchuPicchu

Present in 1.19-pre4.

MacchuPicchu

Present in 1.19-pre5.

MacchuPicchu

Present in 1.19-rc1.

MacchuPicchu

Present in 1.19-rc2.

[Mod] EVGENSYPERPRO

relates to MC-175210 and MCCE-1990

Toast_Cubed

Present in 1.19 full release.

Jean Dubois

Can someone check if this bug affects 1.19.1 pre releases ?

Avoma

Can confirm in 1.19.2.

Kiz

Affects 23w05a.

Ray

It seems to only affect players not mobs with effects.

[media]
Kiz

Affects 23w06a.

Kiz

Affects 23w07a.

Kiz

Affects 1.19.4 Pre-release 1.

Kiz

Affects 1.19.4 Pre-release 3.

Kiz

Affects 1.19.4 Pre-release 4.

Kiz

Affects 1.19.4 Release Candidate 1.

Kiz

Affects 1.19.4 Release Candidate 2.

Kiz

Affects 1.19.4 Release Candidate 3.

Kiz

Affects 23w12a.

Kiz

Affects 23w13a.

Kiz

Affects 23w14a.

Kiz

Affects 23w16a.

Kiz

Affects 23w17a.

Kiz

Affects 23w18a.

Kiz

Affects 1.20 Pre-release 1.

Kiz

Affects 1.20 Pre-release 2.

Kiz

Affects 1.20 Pre-release 4.

Kiz

Affects 1.20 Pre-release 5.

Kiz

Affects 1.20 Pre-release 6.

Kiz

Affects 1.20 Pre-release 7.

NULLYUKI

Can confirm in 1.20.4

CaptainFlame54

Can confirm in 24w06a

Jean Dubois

Can confirm in 24w14a

Bluebird

Affects 1.20.5 Release Candidate 2

Jean Dubois

Can confirm in 24w19b

Joseph Sirna`

[Mod] markderickson

Tommy Wallberg

Confirmed

Platform

Important

Player

effect, end_portal, overworld, potion-effect

Snapshot 13w01b, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1, Minecraft 1.7.4, ..., 23w51b, 24w04a, 24w06a, 1.20.5 Release Candidate 2, 24w19b

24w20a

Retrieved