Skip to main content

A parser for the Minecraft anvil file format

Project description

anvil-parser

Documentation Status Tests PyPI - Downloads

A parser for the Minecraft anvil file format. This package is based on matcool's anvil-parser and supp

Installation

pip install anvil-parser2

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')

Todo

things to do before 1.0.0

  • Proper documentation
  • Biomes
  • CI
  • More tests
    • Tests for 20w17a+ BlockStates format

Note

Testing done in 1.14.4 - 1.19, should work fine for other versions. Writing chunks and regions is broken from 1.16 onwards

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-parser2-0.10.4.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

anvil_parser2-0.10.4-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file anvil-parser2-0.10.4.tar.gz.

File metadata

  • Download URL: anvil-parser2-0.10.4.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for anvil-parser2-0.10.4.tar.gz
Algorithm Hash digest
SHA256 1422bb0dac3823234f0cf66497de7a445623fbb8880548df2200c3791182e4f2
MD5 6de401c6e7b0d77928eccd9900287596
BLAKE2b-256 bde48b6373c3b58698e26224737275809ed2530f80488d337d07451a6595a00f

See more details on using hashes here.

File details

Details for the file anvil_parser2-0.10.4-py3-none-any.whl.

File metadata

File hashes

Hashes for anvil_parser2-0.10.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fd7922242b84bfdf9913dec72776cbecdfe87543bfff369496e2354f8ba8c75b
MD5 e8d92ddcb7b6b73402d749505b1a1bf6
BLAKE2b-256 1def18df289cc4e72e859deb02d8b1ce5a2538b9d4a898819afe012a15c30d4e

See more details on using hashes here.

Supported by

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