Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add JSON mode on exports. #102

Closed
Dkavila opened this issue Jan 24, 2023 · 5 comments
Closed

Feat: Add JSON mode on exports. #102

Dkavila opened this issue Jan 24, 2023 · 5 comments
Labels
feature New feature or request

Comments

@Dkavila
Copy link

Dkavila commented Jan 24, 2023

It will be amazing for the community!!!

@LucasDower
Copy link
Owner

Sure I can add a JSON exporter, is there a particular format you have in mind or just access to block names and their positions?

@LucasDower LucasDower added the feature New feature or request label Jan 24, 2023
@0-zen
Copy link
Contributor

0-zen commented Jan 24, 2023

@LucasDower
Schematic already uses a format that is a bit similar to JSON: https://www.reddit.com/r/Minecraft/comments/k3rrce/is_there_a_way_to_convert_schematic_files_into/

Only repo I found while googling it is:
https://github.com/MicleBrick/Schematic2Json
Which isnt very serious...

Also there are other people asking that question:
https://www.reddit.com/r/MinecraftHelp/comments/tzv3z1/is_there_a_way_to_convert_minecraft_schematics/
But as you can see there are no answers.

As of now it doesnt seem that JSON is used for storing minecraft structure nor that there is a norm for that kind of file. This means that there is no relevant norm (approved or used) that we could choose to implement.

@Dkavila
If you need to have the structure formated in a JSON file for your specific needs, I suggest you fork this repo and create your own norm for that kind of format. This will also provide you with more freedom & knowledge when it comes to programming your parser (to read the JSON files you'll make).

@LucasDower
Copy link
Owner

I imagine the main benefit of a JSON exporter is that it's the easiest to parse, any popular language has JSON libraries so if somebody wants to use the block data somewhere it's a lot easier to load a JSON file than try decipher any of the NBT-based exporters.

Like @0-zen said, it's just about deciding the format. The main concern is that (1) JSON is text-based so encoding is slow, and (2) there's potentially tens of thousands of blocks and JSON is quite verbose so the file could be massive.

We could export something simple like:

[
  { "x": 0, "y": 0, "z": 0, "block": "minecraft:stone" },
  { "x": 1, "y": 8, "z": 7, "block": "minecraft:bedrock" },
  { "x": 2, "y": 1, "z": 4, "block": "minecraft:cobblestone" },
  ...
]

which would be super implement and super simple for an external program to read but is not very suitable for massive builds.

Alternatively we could go down a similar approach to the .gltf format is a JSON file with block data buffers stored as base64 encoded strings.

@0-zen
Copy link
Contributor

0-zen commented Jan 25, 2023

I feel that if we use base64 for encoding, we are going to target people who already know how to program a bit. We might as well create our own binary format, which will be much more compact. Or we could inspire from binary PLY files, which have a structure that starts with a short ASCII header and then binary body.

@LucasDower
Copy link
Owner

Added 'Indexed JSON' and 'Uncompressed JSON' exporters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants