Skip to content

Commit b53eb86

Browse files
committed
also fix on the client side
1 parent ed0df88 commit b53eb86

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/client/play.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,31 @@ module.exports = function (client, options) {
3636
client.username = packet.username
3737

3838
if (mcData.supportFeature('hasConfigurationState')) {
39-
client.write('login_acknowledged', {})
40-
enterConfigState(onReady)
39+
enterConfigState(onReady, () => {
40+
client.write('login_acknowledged', {})
41+
})
4142
// Server can tell client to re-enter config state
4243
client.on('start_configuration', () => enterConfigState())
4344
} else {
4445
client.state = states.PLAY
4546
onReady()
4647
}
4748

48-
function enterConfigState (finishCb) {
49+
function enterConfigState (finishCb, beforeStateSwitch = () => {}) {
4950
if (client.state === states.CONFIGURATION) return
5051
// If we are returning to the configuration state from the play state, we ahve to acknowledge it.
5152
if (client.state === states.PLAY) {
5253
client.write('configuration_acknowledged', {})
5354
}
54-
client.state = states.CONFIGURATION
5555
// Server should send finish_configuration on its own right after sending the client a dimension codec
5656
// for login (that has data about world height, world gen, etc) after getting a login success from client
5757
client.once('finish_configuration', () => {
5858
client.write('finish_configuration', {})
5959
client.state = states.PLAY
6060
finishCb?.()
6161
})
62+
beforeStateSwitch?.()
63+
client.state = states.CONFIGURATION
6264
}
6365

6466
function onReady () {

0 commit comments

Comments
 (0)