@@ -123,35 +123,37 @@ class PlayerSessionAdapter {
123123 handleRequestChunkRadius ( packet ) {
124124 this . player . setViewDistance ( packet . radius ) ;
125125
126- let distance = this . player . getViewDistance ( ) ;
127- for ( let chunkX = - distance ; chunkX <= distance ; chunkX ++ ) {
128- for ( let chunkZ = - distance ; chunkZ <= distance ; chunkZ ++ ) {
129- let chunk = new Chunk ( chunkX , chunkZ ) ;
130-
131- for ( let x = 0 ; x < 16 ; x ++ ) {
132- for ( let z = 0 ; z < 16 ; z ++ ) {
133- let y = 0 ;
134- chunk . setBlockId ( x , y ++ , z , 7 ) ;
135- chunk . setBlockId ( x , y ++ , z , 3 ) ;
136- chunk . setBlockId ( x , y ++ , z , 3 ) ;
137- chunk . setBlockId ( x , y , z , 2 ) ;
138-
139- /*for (let i = y - 1; i >= 0; i--) {
140- chunk.setBlockSkyLight(x, y, z, 0);
141- }*/
126+ Async ( function ( ) {
127+ let distance = this . player . getViewDistance ( ) ;
128+ for ( let chunkX = - distance ; chunkX <= distance ; chunkX ++ ) {
129+ for ( let chunkZ = - distance ; chunkZ <= distance ; chunkZ ++ ) {
130+ let chunk = new Chunk ( chunkX , chunkZ ) ;
131+
132+ for ( let x = 0 ; x < 16 ; x ++ ) {
133+ for ( let z = 0 ; z < 16 ; z ++ ) {
134+ let y = 0 ;
135+ chunk . setBlockId ( x , y ++ , z , 7 ) ;
136+ chunk . setBlockId ( x , y ++ , z , 3 ) ;
137+ chunk . setBlockId ( x , y ++ , z , 3 ) ;
138+ chunk . setBlockId ( x , y , z , 2 ) ;
139+
140+ /*for (let i = y - 1; i >= 0; i--) {
141+ chunk.setBlockSkyLight(x, y, z, 0);
142+ }*/
143+ }
142144 }
143- }
144145
145- // chunk.recalculateHeightMap();
146- //if (chunkX === -distance && chunkZ === -distance) console.log(`${chunk.toBinary().length}`);// > ${chunk.toBinary().toString("hex")}`);
146+ chunk . recalculateHeightMap ( ) ;
147+ if ( chunkX === - distance && chunkZ === - distance ) console . log ( `${ chunk . toBinary ( ) . length } > ${ chunk . toBinary ( ) . toString ( "hex" ) } ` ) ;
147148
148- this . player . sendChunk ( chunk ) ;
149+ this . player . sendChunk ( chunk ) ;
150+ }
149151 }
150- }
151-
152- console . log ( "done sending chunks" ) ;
153- this . player . sendPlayStatus ( PlayStatusPacket . PLAYER_SPAWN ) ;
154-
152+ } . bind ( this ) )
153+ . then ( function ( ) {
154+ console . log ( "done sending chunks" ) ;
155+ this . player . sendPlayStatus ( PlayStatusPacket . PLAYER_SPAWN ) ;
156+ } . bind ( this ) ) ;
155157 return true ;
156158 }
157159
0 commit comments