Universal Tweaks

Universal Tweaks

871k Downloads

๐Ÿ‡ Server mount removal - Horses, Dragons disappear on rejoin server

Krutoy242 opened this issue ยท 4 comments

commented

If player leave server being mounted an entity, this entity would just disappear.

  • This doesn't happen if UT mod is disabled.
  • This doesnt happen on single player.
  • Tested on Horses, Hippogryphs, Dragons.
  • Setting this two options to false doesnt help: Entity Tracker, Mount Desync.
  • This is not recent bug - its about half year old or even older.
  • Was very sad to lost my dragon friend. It was my first dragon, so I called him LostDragon01 ๐Ÿ˜ฅ

My UT configuration: https://github.com/Krutoy242/Enigmatica2Expert-Extended/blob/master/config/Universal%20Tweaks%20-%20Tweaks.cfg

javaw_YsyhAiG3E0.mp4

server debug.log

commented

I can confirm this happens only when Disconnect Dupe=true and only on dedicated servers. From debugging, this happens because there exist two consecutive states of player data, where one ends up overwriting the other in UTDisconnectDupe.

The first state is the player data immediately when the player logs out. This player data passed into PlayerList#playerLoggedOut() is the correct one, in which player.ridingEntity still exists and is not null. In that method, the player data with its mount data is correctly saved to disk.
The second state is sometime after playerLoggedOut() is done executing, which was scheduled to be written to disk here. Because playerLoggedOut() dismounts the player from its mount, the player data in this state will have player.ridingEntity=null. This new state of player data is then saved to disk, overwriting the first state. So when the player rejoins, this player data will be read and their mount will be gone.

In other words, the Disconnect Dupe config option should be default disabled for now as it needs to be reworked. This overwriting of player data corrects a dupe where the player drops item(s) and disconnects while the server is lagging, but it results in a loss of player data as seen here. I assume the data of nanomachines in #398 is also lost because of this.

In the future, one fix for UTDisconnectDupe may be to only schedule a rewrite of the player's inventory data to disk, so the dupe is prevented, but no other player data is lost.

commented

After 4 hours of of restarting and rejoining server, i finally found the config option.

Discord_uhaf5TLhLN

It was

# Fixes item duplications when players are dropping items and disconnecting
B:"Disconnect Dupe"=true

When this option set to true, mount entities and Nanomachines will be removed on disconnect.

commented

Thanks for the detailed analysis, the tweak needs to be reworked indeed. Limited to client side for now.

commented

Accidentally closed issue with commit comment. Issue is still actual.