Skip to content

Commit

Permalink
session/session.go: sendChunks: Always handle world change before move.
Browse files Browse the repository at this point in the history
Resolves #981.
  • Loading branch information
Sandertv committed Jan 3, 2025
1 parent f2b2ef9 commit 65db290
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions server/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,16 @@ func (s *Session) background() {
// sendChunks sends the next up to 4 chunks to the connection. What chunks are loaded depends on the connection of
// the chunk loader and the chunks that were previously loaded.
func (s *Session) sendChunks(tx *world.Tx, c Controllable) {
if w := tx.World(); s.chunkLoader.World() != w && w != nil {
s.handleWorldSwitch(w, tx, c)
}
pos := c.Position()
s.chunkLoader.Move(tx, pos)
s.writePacket(&packet.NetworkChunkPublisherUpdate{
Position: protocol.BlockPos{int32(pos[0]), int32(pos[1]), int32(pos[2])},
Radius: uint32(s.chunkRadius) << 4,
})

if w := tx.World(); s.chunkLoader.World() != w && w != nil {
s.handleWorldSwitch(w, tx, c)
}

s.blobMu.Lock()
const maxChunkTransactions = 8
toLoad := maxChunkTransactions - len(s.openChunkTransactions)
Expand Down

0 comments on commit 65db290

Please sign in to comment.