Convert Minecraft server world files into MCserver world files.
#11
Guess soTongue But I don't think this is completely correct:

(10-28-2011, 02:31 AM)rs2k Wrote: 01 01 01 00
This means Pak V1, Chunk V1, and 1 chunk in file.

The number of chunks is a short (2 bytes).
Like in the decimal system, numbers on the left side have more value than on the right.
If you write down 10, the value is 10 and not 1 like you sayTongue
The number of chunks in that file is ACTUALLY 1*256 + 0 = 256
Reply
Thanks given by:
#12
(10-28-2011, 02:40 AM)FakeTruth Wrote: Guess soTongue But I don't think this is completely correct:

(10-28-2011, 02:31 AM)rs2k Wrote: 01 01 01 00
This means Pak V1, Chunk V1, and 1 chunk in file.

The number of chunks is a short (2 bytes).
Like in the decimal system, numbers on the left side have more value than on the right.
If you write down 10, the value is 10 and not 1 like you sayTongue
The number of chunks in that file is ACTUALLY 1*256 + 0 = 256

256 chunks in a 3KB file? Huh

Here's a screenie of the file:
It's on the far right monitor. I was too lazy to cut the rest. lol
http://dl.dropbox.com/u/14526521/desktop.jpg


Notch's system (Taken from someone else):
=====
Region files begin with an 8kiB header containing information about which chunks are present in the region file, when they were last updated, and where they can be found. The location in the region file of a chunk at (x, z) (in chunk coordinates) can be found at byte offset 4 * ((x mod 32) + (z mod 32) * 32) in its region file. Its timestamp can be found 4096 bytes later in the file. The remainder of the file consists of data for up to 1024 chunks, interspersed with an arbitrary amount of unused space.
=====
The main difference I think I see between your file storage and notch's are his files seem to be a set size. If a chunk is smaller than max size the file is filled with empty data to make it the correct size while your chunks are stored right next to each other with the headers telling us where the chunks start and stop.
Reply
Thanks given by:
#13
Don't know what to say, I must be wrongTongue

Also NICE! 4 screensBig Grin
Reply
Thanks given by:
#14
I'm a bit confused.

I put this code into cChunkMap.cpp


Code:
for( short i = 0; i < NumChunks; ++i )
                {
                        int ChunkX = 0;
                        int ChunkZ = 0;
                        if( fread( &ChunkX, sizeof(ChunkX), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
                        if( fread( &ChunkZ, sizeof(ChunkZ), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", SourceFile); fclose(f); return false; }
                        cChunkData* Data = Layer->GetChunk( ChunkX, ChunkZ );
                        if( Data )
                        {
                                if( fread( &Data->m_CompressedSize, sizeof(Data->m_CompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s", So$
                                if( fread( &Data->m_UncompressedSize, sizeof(Data->m_UncompressedSize), 1, f) != 1 ) { LOGERROR("ERROR READING FROM FILE %s"$
                        }
                        else
                        {
                                LOGERROR("Chunk with wrong coordinates in pak file! %i %i", ChunkX, ChunkZ );
                                fclose(f);
                                return 0;
                        }

                        OrderedData[i] = Data;
                        std::cout << Data << std::endl;
                }


and output looks like this:
0x7f0cc00f7d50


removing std::endl made it looks like this:


0x260ae080x260ae200x260ae980x260b1080x260b1200x260b1980x260b3900x260b3a80x260b4080x260b4200x260b4380x260b4800x260b4980x260b5b80x260b5d00x260b5e80x260b6000x260b6180x260b6300x260b6480x260b6600x260b6780x260b6900x260b6a80x260b6c00x260b6d80x260b6f00x260b7080x260b7200x260b7380x260b7500x260b7680x260b7800x260b7980x260b7e00x260b8b80x260b8d00x260b8e80x260b9000x260b9180x260b9300x260b9480x260b9600x260b9780x260b9900x260b9a80x260b9c00x260b9d80x260b9f00x260ba080x260ba200x260ba380x260ba500x260ba680x260ba800x260ba980x260bab00x260bac80x260bae00x260baf80x260bbb80x260bbd00x260bbe80x260bc000x260bc180x260bc300x260bc480x260bc600x260bc780x260bc900x260bca80x260bcc00x260bcd80x260bcf00x260bd080x260bd200x260bd380x260bd500x260bd680x260bd800x260bd980x260bde00x260bdf80x260beb80x260bed00x260bee80x260bf000x260bf180x260bf300x260bf480x260bf600x260bf780x260bf900x260bfa80x260bfc00x260bfd80x260bff00x260c0080x260c0200x260c0380x260c0500x260c0680x260c0800x260c0980x260c0e00x260c0f80x260c1b80x260c1d00x260c1e80x260c2000x260c2180x260c2300x260c2480x260c2600x260c2780x260c2900x260c2a80x260c2c00x260c2d80x260c2f00x260c3080x260c3200x260c3380x260c3500x260c3680x260c3800x260c3980x260c3c80x260c3e00x260c3f80x260c4b80x260c4d00x260c4e80x260c5000x260c5180x260c5300x260c5480x260c5600x260c5780x260c5900x260c5a80x260c5c00x260c5d80x260c5f00x260c6080x260c6200x260c6380x260c6500x260c6680x260c6800x260c6980x260c6b00x260c6c80x260c6e00x260c6f80x260c7b80x260c7d00x260c7e80x260c8000x260c8180x260c8300x260c8480x260c8600x260c8780x260c8900x260c8a80x260c8c00x260c8d80x260c8f00x260c9080x260c9200x260c9380x260c9500x260c9680x260c9800x260c9980x260c9b00x260cab80x260cad00x260cae80x260cb000x260cb180x260cb300x260cb480x260cb600x260cb780x260cb900x260cba80x260cbc00x260cbd80x260cbf00x260cc080x260cc200x260cc380x260cc500x260cc680x260cc800x260cc980x260ccb00x260cdb80x260cdd00x260cde80x260ce000x260ce180x260ce300x260ce480x260ce600x260ce780x260ce900x260cea80x260cec00x260ced80x260cef00x260cf080x260cf200x260cf380x260cf500x260cf680x260cf800x260cf980x260d0b80x260d0d00x260d0e80x260d1000x260d1180x260d1300x260d1480x260d1600x260d1780x260d1900x260d1a80x260d1c00x260d1d80x260d1f00x260d2080x260d2200x260d2380x260d2500x260d2680x260d2800x260d2980x260d3b80x260d3d00x260d3e80x260d4000x260d4180x260d4300x260d4480x260d4600x260d4780x260d4900x260d4a80x260d4c00x260d4d80x260d4f00x260d5080x260d5200x260d5380x260d5500x260d5680x260d5800x260d5980x260d6b80x260d6d00x260d6e80x260d7000x260d7180x260d7300x260d7480x260d7600x260d7780x260d7900x260d7a80x260d7c00x260d7d80x260d7f00x260d8080x260d8200x260d8380x260d8500x260d8680x260d8800x260d8980x260d9b80x260d9d00x260d9e80x260da000x260da180x260da300x260da480x260da600x260da780x260da900x260daa80x260dac00x260dad80x260daf00x260db080x260db200x260db380x260db500x260db680x260db800x260db980x260dcd00x260dce80x260dd000x260dd180x260dd300x260dd480x260dd600x260dd780x260dd900x260dda80x260ddc00x260ddd80x260ddf00x260de080x260e0180x260e0300x260e0480x260e0600x260e0780x260e0a80x260e0c00x260e0d80x260e3000x260e3180x260e3300x260e3480x260e3600x260e378



Anyway is the compressed chunk data minus the json the same as the compressed chunk data minus the nbt?

So if I ignored the json and converted mcr to pak using only the compressed data, would I get something without entities that MCServer could read? for a start at least.

Reply
Thanks given by:
#15
Pretty much I guess :O Though in the mcr files the chunk data is contained in the NBT structure. In the pak files first comes binary and then JSON so it's not connected.
Reply
Thanks given by:
#16
OK. so I need to parse the NBT data to get the actual chunk data which is:

32768 Bytes Block Types
16384 Bytes Block Meta Data
16384 Bytes Block Light
16384 Bytes Block Sky Light

81920 Bytes Total
Plus Entity stuff
Reply
Thanks given by:
#17
I'm much closer to the goal of being able to convert the data.


I started with PHP since I know that language well. I will more than likely move it to C++ once I figure out.


I've figured out how to get all the chunk data out of the mcr files. I've also been able to uncompressed the chunks. Now I just need to figure out how to read and work with the NBT. I found an NBT php class that I'm trying out right now.

Just for fun echoing the uncompressed NBT chunk info output something like this:

LevelData@€€ˆ€ˆˆˆˆ€ˆ€ˆ€€ˆ€ˆ Entities LastUpdate½•xPoszPos TileEntitiesTerrainPopulatedSkyLight@
Reply
Thanks given by:
#18
Yeah PHP looks a lot like C++ in some ways (mostly function names), so it shouldn't be too hard to convert it to C++
That's some weird looking dataTongue in JSON everything is stored in text which is pretty sweet, because you can actually read it. You can argue that it takes more space, but if you compress it it doesn't
Reply
Thanks given by:
#19
(10-28-2011, 10:24 AM)FakeTruth Wrote: Yeah PHP looks a lot like C++ in some ways (mostly function names), so it shouldn't be too hard to convert it to C++
That's some weird looking dataTongue in JSON everything is stored in text which is pretty sweet, because you can actually read it. You can argue that it takes more space, but if you compress it it doesn't


Success!!...
I think.

I pulled this out a single chunk in an MCR file. It's set to loop over every chunk, but I stopped it at the first one for testing.

Does this look right to you?

Code:
Reading tag "Data" at offset 12
Reading in list of 0 tags of type 1.
Reading tag "Entities" at offset 16407
Reading tag "LastUpdate" at offset 16423
Reading tag "xPos" at offset 16444
Reading tag "zPos" at offset 16455
Reading in list of 0 tags of type 1.
Reading tag "TileEntities" at offset 16466
Reading tag "TerrainPopulated" at offset 16486
Reading tag "SkyLight" at offset 16506
Reading tag "HeightMap" at offset 32905
Reading tag "BlockLight" at offset 33177
Reading tag "Blocks" at offset 49578
Reading tag "Level" at offset 4
Reading tag "" at offset 1
Writing tag "" of type 10
Array
(
    [type] => 10
    [name] =>
    [value] => Array
        (
            [0] => Array
                (
                    [type] => 10
                    [name] => Level
                    [value] => Array
                        (
                            [0] => Array
                                (
                                    [type] => 7
                                    [name] => Data
                                    [value] => Array
                                        (
                                            [0] => 0
                                            [1] => 0
                                            [2] => 0
                                            [3] => 0
                                            [4] => 0
                                            [5] => 0
                                            [6] => 0
                                            [7] => 0
                                            [8] => 0

...... 1, 2, skip a few:

                                            [32753] => 0
                                            [32754] => 0
                                            [32755] => 0
                                            [32756] => 0
                                            [32757] => 0
                                            [32758] => 0
                                            [32759] => 0
                                            [32760] => 0
                                            [32761] => 0
                                            [32762] => 0
                                            [32763] => 0
                                            [32764] => 0
                                            [32765] => 0
                                            [32766] => 0
                                            [32767] => 0
                                        )

                                )

                        )

                )

        )

)
Reply
Thanks given by:
#20
Yeah, guess so :O
Reply
Thanks given by:




Users browsing this thread: 4 Guest(s)