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) <
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.
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.
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)
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:
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:
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:
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!
did you lose the effects or only the indication of the effects, see MC-3668 ?