Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e430895
Add and correct properties of several blocks
NikolaiKirilov Mar 12, 2026
dbd5aac
Remove blockmap conversion related materials because of too many chan…
NikolaiKirilov Mar 12, 2026
fcf60dc
Move PNG related materials off to a subfolder until there is some use…
NikolaiKirilov Mar 12, 2026
6ace008
Refactor the codes to move all functionality into RenderObject class
NikolaiKirilov Mar 12, 2026
3442fc6
Make cli non-interactive with arguments only to convert to litematic …
NikolaiKirilov Mar 12, 2026
03cb01d
Keep notes on blocks which Bloxelizer converter fails to translate co…
NikolaiKirilov Mar 12, 2026
d0ef7ad
Update readme to reflect the current state of the library
NikolaiKirilov Mar 12, 2026
4cedabb
Correct typos and formatting
NikolaiKirilov Mar 12, 2026
617d804
Correct grammar
NikolaiKirilov Mar 12, 2026
e8c2df0
Correct a typo
NikolaiKirilov Mar 12, 2026
d33780c
Add command line parsing
NikolaiKirilov Mar 13, 2026
843ad28
Update readme for the command line changes
NikolaiKirilov Mar 13, 2026
8447a78
Add checking of build's dimensions
NikolaiKirilov Mar 13, 2026
3817442
Recent updates to blockmap
NikolaiKirilov Mar 13, 2026
5f58930
Update blockmap
NikolaiKirilov Mar 13, 2026
754560d
Correct readme
NikolaiKirilov Mar 13, 2026
10b903b
Update block states
NikolaiKirilov Mar 14, 2026
32a3c4e
Introduce GrabCraft's material ID into block mapping
NikolaiKirilov Mar 14, 2026
25b47da
Refactor block mapping codes into dedicated BlockMap class
NikolaiKirilov Mar 16, 2026
e0f58ec
Update blockmap file
NikolaiKirilov Mar 16, 2026
40cd85a
Introduce updating of blockmap with material IDs; update .gitignore
NikolaiKirilov Mar 16, 2026
c1588db
Update blockmap with material IDs
NikolaiKirilov Mar 16, 2026
403ac05
Update readme for the recent blockmap related changes
NikolaiKirilov Mar 16, 2026
ccfb224
Update blockmap with material IDs
NikolaiKirilov Mar 17, 2026
72c8c18
Strip trailing spaces from schema name
NikolaiKirilov Mar 17, 2026
e344e3f
Update blockmap with material IDs
NikolaiKirilov Mar 17, 2026
1ea4dbe
Update blockmap with material IDs; fix water states
NikolaiKirilov Mar 17, 2026
7a25600
Update blockmap with material IDs
NikolaiKirilov Mar 18, 2026
1b6ca58
Update blockmap with material IDs
NikolaiKirilov Mar 19, 2026
65fec4e
Update blockmap with material IDs
NikolaiKirilov Mar 19, 2026
f0eb303
Update blockmap with material IDs
NikolaiKirilov Mar 19, 2026
9b8252e
Update blockmap with material IDs
NikolaiKirilov Mar 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.venv
*.bak
*.orig
\!
*.litematic
*.info
__pycache__
59 changes: 45 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
# grabcraft-to-schema
A Python library and its cli for converting grabcraft to schema (more specifically litematica schematic) files

To use the CLI run `cli.py` (The CLI can be used as an example for how to build your own application using this) <br/>
The library itself is `grabcraft_to_schema.py` <br/>
To use the CLI run `cli.py` (it is also an example of how to use `RenderObject` class). For the list of arguments and optional switches run `cli.py -h`:

Certain blocks can't be easily converted with `auto_block_map()` which is why I used `raw-blockmap.csv` which is the file from https://github.com/gbl/GrabcraftLitematic/blob/master/blockmap.csv, but renamed, and which you can now convert into a form that can be usable by the library but running `clean_blockmap.py` which I got `blockmap.csv` from.
```
usage: cli [-h] [--version] [-f {north,south,east,west}] [-d] url

Download a blueprint from GrabCraft and convert it to a schematic in litematica format

positional arguments:
url URL of the blueprint's page on GrabCraft website

options:
-h, --help show this help message and exit
--version show program's version number and exit
-f {north,south,east,west}
side of the original build facing the bottom of the GrabCraft blueprint
-d dump the contents of the webpage and RenderObject json to a file
```

Upon succesful conversion CLI will output 2 files:
- a schema file in litematica format
- a text file with essential info about the structure, a list (histogram) of the blocks in GrabCraft format and a list of "materials" needed for the build.

## RenderObjects?
GrabCraft, instead of using things like .schematic or .litematic uses its own custom format called RenderObjects. If you're for instance, scraping the web and don't know what data you need to keep or generally want to be able to do stuff without having to worry about certain stuff breaking when dealing with GrabCraft's custom format, I recommend that you guys try to save `RenderObject`'s and their data. The `RenderObject.obj` field is what contains most of the data, which can easily be converted to a json as seen in the library itself since it's just a variable being set to a javascript dictionary which means that it's a json as soon as the javascript variable setting part is removed.

## Some Current Limitations:
Due to me not having the time to sort through all the weird naming used by grabcraft and due to the weird formatting schemes for both grabcraft and Minecraft the nbt (block rotation, whether or not things are lit, etc.) data isn't currently preserved and of course there's no guarantee that all grabcraft builds will work. 99% will work, however it's possible that some weird formatting on grabcraft's part will cause certain builds to not work.
## Orientation
By the looks of it, orientation of each block is kept as it was in the original build from which the blueprint was created. On the other hand, blueprint itself is often re-oriented (publishing guidelines?) and coordinates for each block are assigned according to their location in the published blueprint. If blocks are positioned in a Minecraft world according to those coordinates, the structure will be oriented such that bottom side of the blueprint is facing north. If the orientation of the original build was different, all the individual blocks will be facing the wrong direction.

In order to have each block oriented correctly relative to the build, the library transforms the coordinates specified in the blueprint back to the coordinates of original build. The original orientation of the build is given by the compass in the upper right corner of the blueprint. Both CLI and RenderObject assume the north arrow of the compass is pointing down (toward the bottom of the blueprint). If it is different for particular blueprint, the cardinal direction displayed for the compass down arrow must be specified explicitly (`-f` option of CLI or `north` argument of the RenderObject constructor).

Technically it is possible to extract compass info from the webpage data automatically but the compass itself is unreliable. There are cases where it does not match the actual blocks orientation and in general must be verified manually anyway, e.g. [Small Wooden Cabin 4](https://www.grabcraft.com/minecraft/simple-starter-house-2/wooden-houses#blueprints).

## Block Mapping File
(under construction)

## Current Limitations:
As I only tested this on builds that I'm interested in personally, the library should not be expected to handle every single build offered by GrabCraft. If a structure cannot be converted properly it is likely due to one the following reasons:
- A block has not been seen before and is not present in the block mapping file `blockmap.csv`. Currently if an unknown block is encountered, the library tries to guess the block's identity but the success is not guaranteed and reconstructing the block states from the GrabCraft's free-form naming is practically impossible. The blockmap file with the new entry appended to the bottom of the list will be saved to `blockmap_new.csv`. Correct the ID/state of the new entry, rename the file to `blockmap.csv` and run CLI again.
- Even though present in `blockmap.csv`, many blocks are still missing neccessary states info and, when imported into Minecraft world, might be oriented wrongly, dropped as items and such.

## Documentation:
- `block_map`: The loaded custom blockmap overloads from `blockmap.csv`
- `load_block_map(file_name)`: The function that's used for loading the blockmap csv
- `auto_block_map(grabcraft_block) -> String: schema_block`: The function that's used for automatically mapping blocks over when they aren't in the `block_map`
- `RenderObject`: A class for storing all relevant `RenderObject` data (`.obj`: The JS file containing the main data, `.name`: The build name, `.dims`: \[x, y, z\] list containing dimensions, `.tags`: the description tags)
- `render_object_to_schema(render_object) -> litematic`: This converts a `RenderObject` to a litematic schem
- `render_object_to_png_slice(render_object) -> litematic`: This converts
- `url_to_render_object_data(url) -> RenderObject`: This converts a url to a grabcraft build to a `RenderObject`
- `url_to_png_slice(url) -> PIL.Image`: This converts a url to a png slice.
- `url_to_schema(url) -> litematic`: This converts a url to a litematic schema
- `RenderObject(url, north='north', block_map=None, dump=False)`: the constructor to instantiate an object representing a GrabCraft's blueprint. `url` is link the blueprint's page, `north` is to specify build's orientation if different from blueprint's, `block_map` is for a custom blockmap object. If `dump` is True, GrabCraft webpage and RenderObject JSON file will be saved for inspection.
- `RenderObject.to_schema()`: the user method to convert GrabCraft's blueprint data into litematic schema
- `RenderObject.map_xz(x, z)`: internal method to map coordinates from blueprint to schema
- `RenderObject.map_dims()`: internal method to map build's dimensions from blueprint to schema
- `BlockMap(self, file="blockmap.csv")`: constructor for the blockmap object. Normally the new instance will be created by RenderObject automatically
- `BlockMap.__call__(block_id, block_name)`: the method to convert GrabCraft block names to Minecraft block IDs and states.
- `BlockMap.save(self, filename)`: the method to save blockmap data to CSV file.

## To Do
- After conversion, update 2-tall objects (doors, flowers) for consitency
- Convert to Bedrock's mcstructure format
Loading