Skip to main content

Read and write Litematica's Minecraft schematics files

Project description

Litemapy

Litemapy's goal is to provide an easy to use way to read and edit Litematica's schematic file format in python. Litematica is Minecraft mod by maruohon.

PyPI - Python Version PyPI PyPI - Downloads Commits since latest release Documentation Status

Installation

Litemapy is available on pypi:

pip install litemapy

Features:

  • Read and write .litematic files
  • Full support for litematics' regions concept
  • Full block storage support
  • Full support for basic metadata handling (author, name, description, block count and total volume)
  • Partial support for entities
  • Partial support for tile entities
  • Partial support for pending block updates
  • Partial support for preview images

Documentation

Documentation is available on ReadTheDocs: litemapy.rtfd.io.

Example

Here is a basic example of creating a schematic, and of reading one:

from litemapy import Schematic, Region, BlockState

# Shortcut to create a schematic with a single region
reg = Region(0, 0, 0, 21, 21, 21)
schem = reg.as_schematic(name="Planet", author="SmylerMC", description="Made with litemapy")

# Create the block state we are going to use
block = BlockState("minecraft:light_blue_concrete")

# Build the planet
for x, y, z in reg.allblockpos():
    if round(((x-10)**2 + (y-10)**2 + (z-10)**2)**.5) <= 10:
        reg.setblock(x, y, z, block)

# Save the schematic
schem.save("planet.litematic")

# Load the schematic and get its first region
schem = Schematic.load("planet.litematic")
reg = list(schem.regions.values())[0]

# Print out the basic shape
for x in reg.xrange():
    for z in reg.zrange():
        b = reg.getblock(x, 10, z)
        if b.blockid == "minecraft:air":
            print(" ", end="")
        else:
            print("#", end='')
    print()

When ran, we get the expected output:

       #######       
     ###########     
    #############    
   ###############   
  #################  
 ################### 
 ################### 
#####################
#####################
#####################
#####################
#####################
#####################
#####################
 ################### 
 ################### 
  #################  
   ###############   
    #############    
     ###########     
       #######

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

litemapy-0.8.1b0.tar.gz (32.1 kB view hashes)

Uploaded Source

Built Distribution

litemapy-0.8.1b0-py3-none-any.whl (28.9 kB view hashes)

Uploaded Python 3

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