Decrease size of DB
For now, Craft store EVERY block as row in database in such format:
| p (int) | q (int) | x (int) | y (int) | z (int) | w (int) |
|---|---|---|---|---|---|
| -1 | -1 | -33 | 8 | -33 | -13 |
| -1 | -1 | -33 | 8 | -32 | -13 |
| -1 | -1 | -33 | 8 | -31 | -13 |
Why just not save CHUNK per row for example as HEX string? For example
| p (int) | q (int) | chunk x (int) | chunk y (int) | chunk z (int) | chunk data (string) |
|---|---|---|---|---|---|
| -1 | -1 | 0 | 0 | 0 | 0C FF AE DA 17 ..... |
| -1 | -1 | 0 | 0 | 1 | A0 FA F0 00 A7 ..... |
| -1 | -1 | 0 | 0 | 2 | 00 F1 AA DA 11 ..... |
By this method we can save 16x (chunk size) of memory, because we store chunk XYZ, but not XYZ of EACH block.
p and q identify a chunk, so it's not clear what "chunk x, y and z" are.
Also, only changed blocks are stored in the database. What is your "chunk data"? Is it every block in the chunk? That is 32 * 32 * 256 = 262,144 blocks.
Yes, I called every block in the chunk as chunk data.
I thought, that chunk size is smaller and it in turn is divided into several parts (as in original Minecraft).
Here is NibbleArray and BlockStorage, that I used like in this code:
for (int i=0;i<16;i++) {
sections[i] = new BlockStorage(i);
// Every section can contain 16x16x16 (4096) blocks
// We have 16 sections, so our chunk contains 16x256x16 blocks
}
Thi concept can help you can save many memory on HDD, because you will store 4096 (16_16_16) blocks as one row and can rid of many x-y-z coord pairs in DB.