Fix empty chunks on proxy spawn (#89)
* Fix empty chunks on proxy spawn Hack to fix issue with chunks not loading when client joins the proxy * Queue chunk, respawn packets and only send them after player spawn * fix lint
This commit is contained in:
parent
f0fbf4f859
commit
9cb4a888f4
2 changed files with 20 additions and 4 deletions
|
|
@ -923,7 +923,15 @@ packet_set_spawn_position:
|
|||
packet_animate:
|
||||
!id: 0x2c
|
||||
!bound: both
|
||||
action_id: zigzag32
|
||||
action_id: zigzag32 =>
|
||||
0: none
|
||||
1: swing_arm
|
||||
2: unknown
|
||||
3: wake_up
|
||||
4: critical_hit
|
||||
5: magic_critical_hit
|
||||
6: row_right
|
||||
7: row_left
|
||||
runtime_entity_id: varint64
|
||||
|
||||
packet_respawn:
|
||||
|
|
|
|||
14
src/relay.js
14
src/relay.js
|
|
@ -31,6 +31,7 @@ class RelayPlayer extends Player {
|
|||
this.outLog = this.downOutLog
|
||||
this.inLog = this.downInLog
|
||||
this.chunkSendCache = []
|
||||
this.respawnPacket = []
|
||||
}
|
||||
|
||||
// Called when we get a packet from backend server (Backend -> PROXY -> Client)
|
||||
|
|
@ -54,14 +55,21 @@ class RelayPlayer extends Player {
|
|||
// If we're sending a chunk, but player isn't yet initialized, wait until it is.
|
||||
// This is wrong and should not be an issue to send chunks before the client
|
||||
// is in the world; need to investigate further, but for now it's fine.
|
||||
if (name === 'level_chunk' && this.status !== 3) {
|
||||
this.chunkSendCache.push([name, params])
|
||||
return
|
||||
if (this.status !== 3) {
|
||||
if (name === 'level_chunk') {
|
||||
this.chunkSendCache.push([name, params])
|
||||
return
|
||||
}
|
||||
if (name === 'respawn') this.respawnPacket.push([name, params])
|
||||
} else if (this.status === 3 && this.chunkSendCache.length) {
|
||||
for (const chunk of this.chunkSendCache) {
|
||||
this.queue(...chunk)
|
||||
}
|
||||
for (const rp of this.respawnPacket) {
|
||||
this.queue(...rp)
|
||||
}
|
||||
this.chunkSendCache = []
|
||||
this.respawnPacket = []
|
||||
}
|
||||
this.queue(name, params)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue