@@ -7,6 +7,9 @@ const ResourcePackStackPacket = pocketnode("network/minecraft/protocol/ResourceP
77const ResourcePackChunkRequestPacket = pocketnode ( "network/minecraft/protocol/ResourcePackChunkRequestPacket" ) ;
88const ResourcePackChunkDataPacket = pocketnode ( "network/minecraft/protocol/ResourcePackChunkDataPacket" ) ;
99const RequestChunkRadiusPacket = pocketnode ( "network/minecraft/protocol/RequestChunkRadiusPacket" ) ;
10+ const PlayStatusPacket = pocketnode ( "network/minecraft/protocol/PlayStatusPacket" ) ;
11+
12+ const Chunk = pocketnode ( "level/chunk/Chunk" ) ;
1013
1114const TextPacket = pocketnode ( "network/minecraft/protocol/TextPacket" ) ;
1215
@@ -54,11 +57,12 @@ class PlayerSessionAdapter {
5457 this . server . getLogger ( ) . debugExtensive ( "Status:" , ResourcePackClientResponsePacket . STATUS ( packet . status ) ) ;
5558 switch ( packet . status ) {
5659 case ResourcePackClientResponsePacket . STATUS_REFUSED :
57- this . close ( "" , "You must accept resource packs to join this server." , true ) ;
60+ this . player . close ( "" , "You must accept resource packs to join this server." , true ) ;
5861 break ;
5962
6063 case ResourcePackClientResponsePacket . STATUS_SEND_PACKS :
6164 manager = this . server . getResourcePackManager ( ) ;
65+ packet . packIds . shift ( ) ; //todo figure out why the first id is 00000000-0000-0000-0000-000000000000
6266 for ( let i in packet . packIds ) {
6367 let uuid = packet . packIds [ i ] ;
6468 let pack = manager . getPackById ( uuid ) ;
@@ -118,6 +122,36 @@ class PlayerSessionAdapter {
118122
119123 handleRequestChunkRadius ( packet ) {
120124 this . player . setViewDistance ( packet . radius ) ;
125+
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 z = 0 ; z < 16 ; ++ z ) {
132+ for ( let x = 0 ; x < 16 ; ++ x ) {
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+ chunk . setHeight ( y ) ;
140+
141+ for ( let i = y - 1 ; i >= 0 ; i -- ) {
142+ chunk . setBlockSkyLight ( x , y , z , 0 ) ;
143+ }
144+ }
145+ }
146+
147+ chunk . recalculateHeightMap ( ) ;
148+
149+ this . player . sendChunk ( chunk ) ;
150+ }
151+ }
152+
153+ this . player . sendPlayStatus ( PlayStatusPacket . PLAYER_SPAWN ) ;
154+
121155 return true ;
122156 }
123157
0 commit comments