@@ -36,29 +36,31 @@ module.exports = function (client, options) {
36
36
client . username = packet . username
37
37
38
38
if ( mcData . supportFeature ( 'hasConfigurationState' ) ) {
39
- client . write ( 'login_acknowledged' , { } )
40
- enterConfigState ( onReady )
39
+ enterConfigState ( onReady , ( ) => {
40
+ client . write ( 'login_acknowledged' , { } )
41
+ } )
41
42
// Server can tell client to re-enter config state
42
43
client . on ( 'start_configuration' , ( ) => enterConfigState ( ) )
43
44
} else {
44
45
client . state = states . PLAY
45
46
onReady ( )
46
47
}
47
48
48
- function enterConfigState ( finishCb ) {
49
+ function enterConfigState ( finishCb , beforeStateSwitch = ( ) => { } ) {
49
50
if ( client . state === states . CONFIGURATION ) return
50
51
// If we are returning to the configuration state from the play state, we ahve to acknowledge it.
51
52
if ( client . state === states . PLAY ) {
52
53
client . write ( 'configuration_acknowledged' , { } )
53
54
}
54
- client . state = states . CONFIGURATION
55
55
// Server should send finish_configuration on its own right after sending the client a dimension codec
56
56
// for login (that has data about world height, world gen, etc) after getting a login success from client
57
57
client . once ( 'finish_configuration' , ( ) => {
58
58
client . write ( 'finish_configuration' , { } )
59
59
client . state = states . PLAY
60
60
finishCb ?. ( )
61
61
} )
62
+ beforeStateSwitch ?. ( )
63
+ client . state = states . CONFIGURATION
62
64
}
63
65
64
66
function onReady ( ) {
0 commit comments