Skip to main content

Parser and editor for Luanti worlds

Project description

mtanvil

A Python library for parsing and editing Luanti worlds.

The name comes from Luanti’s former name (‘MT’ for Minetest) and the Minecraft world parsing library ‘anvil’

This is extremely under development so please don't use this for any major projects right now. Future updates will have breaking changes.

However, testing is welcome so please do open an issue if you find problems with it.

mtanvil fully supports MapBlock format version 29 (latest). Other versions may not be fully supported but should receive full support in the future.

It is recommended that you familiarize yourself with the Map File Format and MapBlock Serialization Format so that you fully understand what data mtanvil provides.

Usage

Currently mtanvil is not available as a package (yet), so you must download mtanvil.py and put it in the same directory as the file that will import it.

First of all, import mtanvil with

import mtanvil as anvil

You can then load a world file:

world = anvil.World.from_file('/path/to/map.sqlite')

World functions

  • world.list_mapblocks(): Returns a list of all MapBlocks present in the world file

  • world.get_mapblock(pos): Returns a MapBlock. pos should be a tuple of the XYZ coords, eg (5, -4, 18)

  • world.set_mapblock(pos, data): Writes a MapBlock to the world. data should be serialized, see MapBlock's functions

NOTE: you should ensure that the world is currently not in use by Luanti before writing to it

  • world.get_all_mapblocks(): Returns all MapBlocks present in the world file. Each list item is a tuple: (X, Y, Z, MapBlock)

  • world.close(): Closes the database connection. It is recommended to run this once you're finished with the World

MapBlock functions

  • mapblock.data: Dictionary of the parsed data

  • mapblock.parse(data): Returns a dictionary of the parsed data. data must be a raw binary blob from the database

  • mapblock.set_node(pos, param0, param1 = 0, param2 = 0): Sets the node at the specified co-ordinates. param0 is the node name, eg default:goldblock

  • mapblock.serialize(data = None, compressed = True): Turns dictionary of parsed data back into binary. If data is None, mapblock.data will be serialized instead. compressed is required for Luanti MapBlock format version 29+

Utility functions

  • pos_get_mapblock(pos): Returns a tuplet with the position of the MapBlock that has the world co-ordinates provided

  • pos_get_node(pos): Returns a tuplet with the position within the relevant MapBlock (see function above) of the world co-ordinates provided

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtanvil-0.1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mtanvil-0.1.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file mtanvil-0.1.0.tar.gz.

File metadata

  • Download URL: mtanvil-0.1.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mtanvil-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c904b8cb43b65b337aa28ead0a43a9e7e63c05dec9551a9eb9dc2fd84639178
MD5 1dbe7c665d1bfa91edc51f182173115e
BLAKE2b-256 2f7a672f06f7978f10ed6f789cbd32352671e1d14d7c0cbff9de9b1bbb7bee29

See more details on using hashes here.

Provenance

The following attestation bundles were made for mtanvil-0.1.0.tar.gz:

Publisher: python-publish.yml on fancyfinn9/mtanvil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mtanvil-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mtanvil-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mtanvil-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca57568474aab57e43b4ec43032a9bda04555d7117993f4ce29470f9973e709e
MD5 15b567a5db3cbbfee0fd104016365ad6
BLAKE2b-256 4aecf213d490ed6f339ae7bea5511de05267cf662211c2353b02a844361b2dda

See more details on using hashes here.

Provenance

The following attestation bundles were made for mtanvil-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on fancyfinn9/mtanvil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page