Minetest world parsing

Post Reply
User avatar
MCL
Member
Posts: 654
Joined: Mon Aug 20, 2018 00:44
GitHub: MCLx86
IRC: migdyn
In-game: singleplayer
Contact:

Minetest world parsing

by MCL » Post

Good night,
this is related to my previous thread
I am trying to write a Minetest -> MineCraft map converter and while I have the MineCraft part (mostly) figured out,
I got stuck on the Minetest part. Do you know of any libraries for reading Minetest world? It would be best if they were
Python libraries, because I already started writing the MineCraft part in Python 3.9. If there aren't any pre-made libraries,
could you provide me with some other open source projects that read Minetest save files?

Thank you all for your help.
2014-02-14 - 2024-02-14 TEN YEARS OF MCL

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: Minetest world parsing

by bzt » Post

Hi,

The documentation is here.

Basically it is an sqlite3 database, which you should have no probs reading with python. The map data is stored in the table "blocks". It has two coloumns: one is "pos", which is generated from the coordinates, and the other one is "data", which contains a zlib deflated, serialized 16 x 16 x 16 node chunk.

There used to be a python script to generate the map from the sqlite, but it had been deprecated and replaced by a C++ implementation, minetestmapper.

The problematic part is, only those mapchunks are stored which have been modified by the players. So in order to get a full map, you'll have to interpret the mapgen parameters as well and generate the map, then read the blocks and modify that generated map to get the final result. As far as I know, only Amidst supports that (showing the parts of the map which are not stored in the sqlite). It is in java, but maybe you can learn from its source. I don't know how up-to-date it is with the latest mapgens, though.

Alternatively you could check out the mods. There are several that can save parts of the world into different formats. For example, WorldEdit is scriptable and can save .we files, which is a Lua table that you can easily parse from python, and the advantage is that since it is saved in game, it already contains both the generated and modified parts of the world. If none suits your needs, you can write a Lua mod using the VoxelManip API (get_data and get_node_at) and save the data into whatever format you want.

Cheers,
bzt

User avatar
bobomb
Member
Posts: 162
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Minetest world parsing

by bobomb » Post

i once had a python library that interacted with the world sqlite db directly. i cannot find it anywhere now though but be assured such a thing existed. it was called minetestlib or something like that.i will check an old laptop to see if i can find it.

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Minetest world parsing

by Blockhead » Post

bobomb wrote:
Sat Jan 14, 2023 21:56
i once had a python library that interacted with the world sqlite db directly. i cannot find it anywhere now though but be assured such a thing existed. it was called minetestlib or something like that.i will check an old laptop to see if i can find it.
You are probably thinking of python-minetest, but that is quite old and won't support the newer zstd compression.

Here are some project I already knew of or found from a quick search. Some don't do modifications though, just reading:
  • Rust library - minetestworld
  • Go application - mapserver - does the rendering itself, must be parsing the world format.
  • C++ application - minetestmapper - renders worlds.
  • and of course the classic Python application, mcimport, but I can't vouch for what versions of MT or MC it supports.
There may be others, but those first three I know will work with the latest versions of the game.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
bobomb
Member
Posts: 162
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Minetest world parsing

by bobomb » Post

MCL wrote:
Fri Jun 25, 2021 01:44
Good night,
this is related to my previous thread
I am trying to write a Minetest -> MineCraft map converter and while I have the MineCraft part (mostly) figured out,
I got stuck on the Minetest part. Do you know of any libraries for reading Minetest world? It would be best if they were
Python libraries, because I already started writing the MineCraft part in Python 3.9. If there aren't any pre-made libraries,
could you provide me with some other open source projects that read Minetest save files?

Thank you all for your help.
The python-minetest library that parses the world db is being worked on to update it to the newer minetest format with zstd compression:

https://github.com/Lymkwi/python-minetest/issues/19

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests