@@ -156,11 +156,11 @@ public void loadRegion() {
156
156
}
157
157
}
158
158
if (loadGeneratedMap ) {
159
- for (int z = 0 ; z < 4 ; z ++) {
160
- for (int x = 0 ; x < 13 ; x ++) {
161
- for (int y = 0 ; y < 13 ; y ++) {
162
- int data = constructMapTiles [z ][ x ][ y ];
163
- boolean bool_19_ = false ;
159
+ for (int plane = 0 ; plane < 4 ; plane ++) {
160
+ for (int chunkX = 0 ; chunkX < 13 ; chunkX ++) {
161
+ for (int chunkY = 0 ; chunkY < 13 ; chunkY ++) {
162
+ int data = constructMapTiles [plane ][ chunkX ][ chunkY ];
163
+ boolean chunkLoaded = false ;
164
164
if (data != -1 ) {
165
165
int tileRotation = (0x6 & data ) >> 1 ;
166
166
int tileX = (data & 0xffd2c2 ) >> 14 ;
@@ -169,14 +169,14 @@ public void loadRegion() {
169
169
int tileCoordinates = (tileX / 8 << 8 ) + tileY / 8 ;
170
170
for (int pointer = 0 ; pointer < mapCoordinates .length ; pointer ++) {
171
171
if (mapCoordinates [pointer ] == tileCoordinates && terrainData [pointer ] != null ) {
172
- loadTerrainSubblock (y * 8 , 8 * (tileX & 0x7 ), tileZ , z , x * 8 , (0x7 & tileY ) * 8 , tileRotation , terrainData [pointer ], currentCollisionMap );
173
- bool_19_ = true ;
172
+ loadTerrainSubblock (chunkY * 8 , 8 * (tileX & 0x7 ), tileZ , plane , chunkX * 8 , (0x7 & tileY ) * 8 , tileRotation , terrainData [pointer ], currentCollisionMap );
173
+ chunkLoaded = true ;
174
174
break ;
175
175
}
176
176
}
177
177
}
178
- if (!bool_19_ )
179
- method455 ( 8 * y , z , x * 8 );
178
+ if (!chunkLoaded )
179
+ matchChunkHeightmapWithSurroundings ( plane , chunkX * 8 , chunkY * 8 );
180
180
}
181
181
}
182
182
}
@@ -1320,25 +1320,29 @@ private void initiateVertexHeights(int offsetY, int sizeY, int sizeX, int offset
1320
1320
}
1321
1321
}
1322
1322
1323
- private void method455 (int arg0 , int arg1 , int arg3 ) {
1324
- for (int i = 0 ; i < 8 ; i ++) {
1325
- for (int i_0_ = 0 ; i_0_ < 8 ; i_0_ ++)
1326
- tile_height [arg1 ][arg3 + i ][arg0 + i_0_ ] = 0 ;
1323
+ /**
1324
+ * Adjusts the height of tiles around a chunk's perimeter
1325
+ */
1326
+ private void matchChunkHeightmapWithSurroundings (int plane , int tileX , int tileY ) {
1327
+ // clear the chunk's height values
1328
+ for (int x = 0 ; x < 8 ; x ++) {
1329
+ for (int y = 0 ; y < 8 ; y ++)
1330
+ tile_height [plane ][tileX + x ][tileY + y ] = 0 ;
1327
1331
}
1328
- if (arg3 > 0 ) {
1329
- for (int i = 1 ; i < 8 ; i ++)
1330
- tile_height [arg1 ][ arg3 ][ arg0 + i ] = tile_height [arg1 ][- 1 + arg3 ][ i + arg0 ];
1332
+ if (tileX > 0 ) {
1333
+ for (int y = 1 ; y < 8 ; y ++)
1334
+ tile_height [plane ][ tileX ][ tileY + y ] = tile_height [plane ][ tileX - 1 ][ y + tileY ];
1331
1335
}
1332
- if (arg0 > 0 ) {
1333
- for (int i = 1 ; i < 8 ; i ++)
1334
- tile_height [arg1 ][ i + arg3 ][ arg0 ] = tile_height [arg1 ][ i + arg3 ][- 1 + arg0 ];
1336
+ if (tileY > 0 ) {
1337
+ for (int x = 1 ; x < 8 ; x ++)
1338
+ tile_height [plane ][ tileX + x ][ tileY ] = tile_height [plane ][ tileX + x ][ tileY - 1 ];
1335
1339
}
1336
- if (arg3 > 0 && tile_height [arg1 ][- 1 + arg3 ][ arg0 ] != 0 )
1337
- tile_height [arg1 ][ arg3 ][ arg0 ] = tile_height [arg1 ][ arg3 - 1 ][arg0 ];
1338
- else if (arg0 > 0 && tile_height [arg1 ][ arg3 ][ arg0 - 1 ] != 0 )
1339
- tile_height [arg1 ][ arg3 ][ arg0 ] = tile_height [arg1 ][ arg3 ][- 1 + arg0 ];
1340
- else if (arg3 > 0 && arg0 > 0 && tile_height [arg1 ][ arg3 + - 1 ][- 1 + arg0 ] != 0 )
1341
- tile_height [arg1 ][ arg3 ][ arg0 ] = tile_height [arg1 ][- 1 + arg3 ][ arg0 - 1 ];
1340
+ if (tileX > 0 && tile_height [plane ][ tileX - 1 ][ tileY ] != 0 )
1341
+ tile_height [plane ][ tileX ][ tileY ] = tile_height [plane ][ tileX - 1 ][tileY ];
1342
+ else if (tileY > 0 && tile_height [plane ][ tileX ][ tileY - 1 ] != 0 )
1343
+ tile_height [plane ][ tileX ][ tileY ] = tile_height [plane ][ tileX ][ tileY - 1 ];
1344
+ else if (tileX > 0 && tileY > 0 && tile_height [plane ][ tileX - 1 ][tileY - 1 ] != 0 )
1345
+ tile_height [plane ][ tileX ][ tileY ] = tile_height [plane ][ tileX - 1 ][ tileY - 1 ];
1342
1346
}
1343
1347
1344
1348
private static int generateHslBitset (int s , int l , int h ) {
0 commit comments