Basically the blueprint files contain various meta data, followed by the preview image (thumbnail and screenshot, both in JPG format), followed by the actual building data (which is compressed)
The first bytes of the blueprint (basically the header) contains information about where the data is located in the buffer.
Blueprint data endianness in the new version is always Little Endian.
The very first byte contains the blueprint version, currently (as of 0.4.5) it is version 6. We use the version for compatibility checks in future updates (possibly the format may slightly change in a future update, so that would be indicated by the version number).
Java blueprints use a different format btw. Since they use the same file ending (".blueprint"), you can check if it's a Java blueprint by having a look at the first three bytes: In the Java version, the whole blueprint data was GZIP compressed, so if the first byte is always "31", the second byte is "139", and the third byte is less or equal to "8", it's most likely a Java blueprint. Java blueprints use Big Endian btw, but that's a different story. Once a Java blueprint is loaded in the new version, it gets converted to the new version format automatically.
The whole data structure of a blueprint in the new version looks like this:
HEADER
| Number of bytes |
Data |
| 1 | blueprint version |
| 4 | total number of bytes in blueprint data |
| 4 | start position of meta data in buffer |
| 4 | length of meta data (in bytes) |
| 4 | start position of thumbnail image in buffer |
| 4 | length of thumbnail data (in bytes) |
| 4 | start position of screenshot data in buffer |
| 4 | length of screenshot data (in bytes) |
| 4 | start position of actual blueprint data in buffer |
| 4 | length of actual blueprint data (in bytes) |
META DATA
| Number of bytes |
Data |
| 1 | is legacy blueprint (from Java version)? |
| 8 | blueprint creation date (unix timestamp) |
| 4 | relative x coordinate of the blueprint center (float) |
| 4 | relative y coordinate of the blueprint center(float) |
| 4 | relative z coordinate of the blueprint center(float) |
| 4 | extent/size of the blueprint along x axis(float) |
| 4 | extent/size of the blueprint along y axis(float) |
| 4 | extent/size of the blueprint along z axis(float) |
| 2 + xx |
blueprint name (string*) |
| 2 + xx |
creator name (string*) |
| 2 + xx |
creator uid (string*) |
| 2 + xx |
name of world where blueprint was created (string*) |
THUMBNAIL DATA
| Number of bytes | Data |
| 2 | thumbnail width (pixels) |
| 2 | thumbnail height (pixels) |
| 2 + xx |
thumnail format (string*), currently always "JPG" |
| 4 | number of bytes of thumbnail image data |
| xx | thumbnail image data |
SCREENSHOT DATA
| Number of bytes | Data |
| 2 | screenshot width (pixels) |
| 2 | screenshot height (pixels) |
| 2 + xx |
screenshot format (string*), currently always "JPG" |
| 4 | number of bytes of screenshot image data |
| xx | screenshot image data |
BLUEPRINT CONTENT
| Number of bytes | Data |
| 4 | compressed blueprint data length (+ 4 bytes for uncompressed len) |
| 4 | uncompressed data length |
| xx | LZ4 compressed blueprint data |
UNCOMPRESSED BLUEPRINT DATA (LZ4)
| Number of bytes | Data |
| 4 | number of construction elements in blueprint |
| xx | serialized construction data (see below) |
| 4 | number of object elements in blueprint |
| xx | serialized object data (see below) |
| 4 | number of plants in blueprint |
| xx | serialized plant data (see below) |
| 4 | terrain array length in blueprint |
| xx | serialized terrain data |
SERIALIZED CONSTRUCTION DATA (per element)
| Number of bytes | Data |
| 4 | relative x position (float) |
| 4 | relative y position (float) |
| 4 | relative z position (float) |
| 4 | rotation x value (quaternion) |
| 4 | rotation y value (quaternion) |
| 4 | rotation z value (quaternion) |
| 4 | rotation w value (quaternion) |
| 4 | size along x (float) |
| 4 | size along y (float) |
| 4 | size along z (float) |
| 1 | construction type id |
| 4 | texture |
| 4 | RGBA color (int) - currently unused |
| 4 | RGBA color (int) - currently unused |
| 4 | RGBA color (int) - currently unused |
| 4 | RGBA color (int) - currently unused |
| 4 | RGBA color (int) - currently unused |
| 4 | RGBA color (int) |
| 4 | surface x offset (float) |
| 4 | surface y offset (float) |
| 4 | surface z offset (float) |
| 4 | surface x scale (float) |
| 4 | surface y scale (float) |
| 4 | surface z scale (float) |
| 4 | optional thickness (float) |
| 4 | texture scale factor (float) |
| 4 | optional additional flags (int bitmask) |
SERIALIZED OBJECT DATA (per element)
| Number of bytes | Data |
| 4 | relative x position (float) |
| 4 | relative y position (float) |
| 4 | relative z position (float) |
| 4 | rotation x value (quaternion) |
| 4 | rotation y value (quaternion) |
| 4 | rotation z value (quaternion) |
| 4 | rotation w value (quaternion) |
| 4 | size along x (float) |
| 4 | size along y (float) |
| 4 | size along z (float) |
| 2 | object type id |
| 4 | variation |
| 4 | RGBA color (int) |
| 1 | status |
| 8 |
additional object info (long) |
| 4 | optional additional flags (int bitmask) |
SERIALIZED PLANT DATA (per element)
| Number of bytes | Data |
| 4 | relative x position (float) |
| 4 | relative y position (float) |
| 4 | relative z position (float) |
| 4 | rotation x value (quaternion) |
| 4 | rotation y value (quaternion) |
| 4 | rotation z value (quaternion) |
| 4 | rotation w value (quaternion) |
| 4 | size along x (float) |
| 4 | size along y (float) |
| 4 | size along z (float) |
| 2 | plant type id |
| 1 |
is plant cut? |
| 4 | optional additional flags (int bitmask) |
SERIALIZED TERRAIN DATA
| Number of bytes | Data |
| 4 | terrain array size x |
| 4 | terrain array size y |
| 4 | terrain array size z |
| 2 * size x * size y * size z |
terrain data array (short[]) |
Terrain data is a flattened 3d array consisting of shorts, where the first 8 bits contain the optional terrain "strength" or density between 0 and 100 (used to apply additional smoothing to the terrain) and the last 8 bits contain the actual terrain ID (0 is air).
To get the index in the terrain array from an x, y and z value, you can use this code: x + y * sizeX + z * sizeX * sizeY
I hope I didn't miss anything ![]()
* when it comes to strings, the buffer first stores the number of characters as 16 bit int (short), then the individual characters (2 bytes per char). If the string is null, a "-1" is stored instead (again as 16 bit int)