Skip to main content

A library for working with Minecraft Schematics in Python with numpy

Project description

PySchematic - Minecraft Schematic Library

PySchematic is a Python library for working with Minecraft schematic files. It provides a simple and convenient way to read and process schematic files used in Minecraft.

The library is based on the Minecraft Schematic format version 2.

Features

  • Load Minecraft schematic files (.schematic) and read their contents.
  • Access schematic size and dimensions (width, height, length).
  • Get block data as a 3D numpy array representing the blocks in the schematic.
  • Access individual blocks' information, including type and properties.

Installation

To install PySchematic, you can use pip:

pip install pyschematic

Usage

Here's a quick guide on how to use the PySchematic library:

Schematic Class

The Schematic class is the main class of the library. It is used to load schematic files with the load method and access the schematic's data.

from pyschematic import Schematic

schematic = Schematic().load('path/to/your/schematic_file.schematic')

print(schematic.size)     # Output: (3, 4, 5)
print(schematic.width)    # Output: 3
print(schematic.height)   # Output: 4
print(schematic.length)   # Output: 5

# Get block data as a 3D numpy array
blocks = schematic.blocks
print(blocks.shape)      # Output: (3, 4, 5)
print(blocks[0, 0, 0])   # Output: Block(minecraft:redstone_wire[east=none,north=side,power=0,south=side,west=none])

# Get the positions of each block as their schematic id in a 1D numpy array
block_data = schematic.block_data
print(block_data)        # Output: [1, 2, 1, 1, 1, 3...]

# Get the offset of the schematic
offset = schematic.offset
print(offset)            # Output: (15, 3, 4)

# Or for the WorldEdit offset
we_offset = schematic.worldedit_offset
print(we_offset)         # Output: (15, 3, 4)

# Get additional metadata (if available)
metadata = schematic.metadata
print(metadata)          # Output: { 'Metadata_key_1': 'Metadata_value_1', ... }

Note: The schematic loading process will verify the schematic's version and raise an exception if it is not compatible with version 2. To force loading the schematic (not recommended), you can pass force=True to the load method.

Requirements

  • Python 3.10+
  • numpy
  • nbtlib

Contributing

If you have any suggestions, bug reports, or feature requests, please feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.


This project is based on the Minecraft Schematic format version 2.

Author: Gabriel Werneck Paiva

Email: gwerneckpaiva@gmail.com

GitHub: Your GitHub Profile

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

minecraftschematics-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

minecraftschematics-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: minecraftschematics-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for minecraftschematics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ccd75e7cf771de6e13997fb8884e5fb284d3ec5aba5adc22748709cc3bde4d4c
MD5 ec5023d50f9f19804711b608d8465da6
BLAKE2b-256 a1ea433134dffb8314c63f407830506664977b77f80a7955f0029af006f8ba00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for minecraftschematics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cca62ccc850781c51551e4b35111d0f8811941c3c064f7173ee4ee0d61e78ae6
MD5 355853a021b3c56c0d54c5974a3b2e78
BLAKE2b-256 6b7cef5c852c17c3bd6f6498af229a62c0cfc1549f630b194a4ba6210cf2914b

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