Skip to content

Commit 31b85f3

Browse files
authored
[Savestates] Attempt at fixing velocity being reset on loadstate (#244)
One tick after a loadstate, the velocity of the player will be reset for one tick, which desyncs the rest of the TAS. I was able to trace the issue back to the NetHandlerPlayServer, where the player is processed. If the player is not added to the chunk on the server side, a collision check with the nearest block would fail (kinda like walking into unloaded chunks) and the velocity would be reset to 0, which would then get sent to the client. To fix this, I add the player to yet another chunk variable. Hopefully this will not bite me in the future
2 parents 3f066c2 + 27d9a3a commit 31b85f3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/minecrafttas/tasmod/savestates/handlers/SavestateWorldHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ private void addPlayerToChunkMap(WorldServer world, EntityPlayerMP player) {
157157
} else {
158158
playerChunkMap.addPlayer(player);
159159
}
160-
world.getChunkProvider().provideChunk(playerChunkPosX, playerChunkPosY);
160+
Chunk chunk = world.getChunkProvider().provideChunk(playerChunkPosX, playerChunkPosY);
161+
chunk.addEntity(player);
161162

162163
world.spawnEntity(player);
163164
}
@@ -239,7 +240,6 @@ public void loadAllWorlds(String string, String string2) {
239240
}
240241

241242
server.worlds[i].addEventListener(new ServerWorldEventHandler(server, server.worlds[i]));
242-
server.worlds[i].tick(); // TODO I give up...
243243
}
244244

245245
server.getPlayerList().setPlayerManager(server.worlds);

0 commit comments

Comments
 (0)