Skip to main content

A Minecraft anvil file format parser

Project description

anvil-parser

Documentation Status

PyPI - Downloads

Simple parser for the Minecraft anvil file format

Installation

This is a fork of the original anvil-parser with modern type annotations and improvements.

Install from PyPI:

pip install anvil-parser-modern

Install directly from this GitHub repository:

# Users
pip install git+https://github.com/voidfemme/anvil-parser.git

# Contributors
pip install -r requirements-dev.txt
pip install -e .

Or clone and install locally:

git clone https://github.com/voidfemme/anvil-parser.git
cd anvil-parser
pip install -e

Usage

Reading

import anvil

region = anvil.Region.from_file('r.0.0.mca')

# You can also provide the region file name instead of the object
chunk = anvil.Chunk.from_region(region, 0, 0)

# If `section` is not provided, will get it from the y coords
# and assume it's global
block = chunk.get_block(0, 0, 0)

print(block) # <Block(minecraft:air)>
print(block.id) # air
print(block.properties) # {}

Making own regions

import anvil
from random import choice

# Create a new region with the `EmptyRegion` class at 0, 0 (in region coords)
region = anvil.EmptyRegion(0, 0)

# Create `Block` objects that are used to set blocks
stone = anvil.Block('minecraft', 'stone')
dirt = anvil.Block('minecraft', 'dirt')

# Make a 16x16x16 cube of either stone or dirt blocks
for y in range(16):
    for z in range(16):
        for x in range(16):
            region.set_block(choice((stone, dirt)), x, y, z)

# Save to a file
region.save('r.0.0.mca')

Requirements

  • Python 3.10+ (for modern type annotation syntax)
  • NBT >= 1.5.1
  • frozendict >= 2.3.0

Changes from Original

This fork includes the following improvements:

  • Modern Python type annotations using 'X | None' syntax
  • Enhanced null safety throughout the codebase
  • Bug fixes in block comparison methods
  • Improved code organization with base classes
  • Python 3.13 compatibility
  • Updated dependencies
  • pathlib.Path support for modern file handling

Todo

things to do before 1.0.0

  • Proper documentation
  • Add support for Minecraft version 1.21.4 and 1.21.5
  • Biomes
  • CI
  • More tests
    • Tests for 20w17a+ BlockStates format

Note

Testing done in 1.14.4 and 1.15.2, more versions to be supported soon!

Maintainer

This fork is actively maintained by voidfemme.

Original project: matcool/anvil-parser (archived) Forked from: lexi-the-cute/anvil-parser

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

anvil_parser_modern-0.10.0.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

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

anvil_parser_modern-0.10.0-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file anvil_parser_modern-0.10.0.tar.gz.

File metadata

  • Download URL: anvil_parser_modern-0.10.0.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for anvil_parser_modern-0.10.0.tar.gz
Algorithm Hash digest
SHA256 3847d9370c3f4c3509ae52f38416134cf8a2fe0bef249fc70ffca5e158440bbb
MD5 a08d15edd5b74cd77b6f340d5d7ab505
BLAKE2b-256 fbe41260e6d837a63f4727fed9c37e82a245008e2cdaf15c814fb9722119018e

See more details on using hashes here.

File details

Details for the file anvil_parser_modern-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anvil_parser_modern-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d7c079bbf96fa00debbe4bf4f06c95e5888d04d7661aa6cc4a1d3c0632ad0e2
MD5 b8932ea543ffc9d64bf08a2b57711957
BLAKE2b-256 1ce3b923ddc83bad3923c3272ad9bcf33afa581d8c3b0ddbba214a9cc07138c2

See more details on using hashes here.

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