Skip to main content

A powerful Minecraft command library

Project description

logo

Mecha

GitHub Actions PyPI PyPI - Python Version Code style: black

A powerful Minecraft command library.

from mecha import Mecha

mc = Mecha()

function = """
    execute
        as @a                        # For each "player",
        at @s                        # start at their feet.
        anchored eyes                # Looking through their eyes,
        facing 0 0 0                 # face perfectly at the target
        anchored feet                # (go back to the feet)
        positioned ^ ^ ^1            # and move one block forward.
        rotated as @s                # Face the direction the player
                                     # is actually facing,
        positioned ^ ^ ^-1           # and move one block back.
        if entity @s[distance=..0.6] # Check if we're close to the
                                     # player's feet.
        run
            say I'm facing the target!
"""

ast = mc.parse(function, multiline=True)
print(mc.serialize(ast))  # execute as @a at @s anchored eyes facing ...

Introduction

This package provides everything you need for working with Minecraft commands in Python, whether you're looking to process commands or build abstractions on top.

Features

  • Extensible and version-agnostic mcfunction parser
  • Clean abstract syntax tree with source location
  • Command config resolver that flattens all the valid prototypes
  • Powerful rule dispatcher for processing specific ast nodes
  • Composable visitors and reducers
  • (soon) Execute arbitrary compilation passes in your beet pipeline
  • (soon) Expressive command API for writing commands in Python

Installation

The package can be installed with pip.

$ pip install mecha

Contributing

Contributions are welcome. Make sure to first open an issue discussing the problem or the new feature before creating a pull request. The project uses poetry.

$ poetry install

You can run the tests with poetry run pytest.

$ poetry run pytest

The project must type-check with pyright. If you're using VSCode the pylance extension should report diagnostics automatically. You can also install the type-checker locally with npm install and run it from the command-line.

$ npm run watch
$ npm run check

The code follows the black code style. Import statements are sorted with isort.

$ poetry run isort mecha tests
$ poetry run black mecha tests
$ poetry run black --check mecha tests

License - MIT

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

mecha-0.3.0.tar.gz (48.8 kB view details)

Uploaded Source

Built Distribution

mecha-0.3.0-py3-none-any.whl (53.3 kB view details)

Uploaded Python 3

File details

Details for the file mecha-0.3.0.tar.gz.

File metadata

  • Download URL: mecha-0.3.0.tar.gz
  • Upload date:
  • Size: 48.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.5 Linux/4.19.128-microsoft-standard

File hashes

Hashes for mecha-0.3.0.tar.gz
Algorithm Hash digest
SHA256 92bf06533b0a086a8a67d5c3e9fde6109f84e47a816b395a7c652b887bfe6921
MD5 f148f622561f94e3cb72e1a5e474c6ab
BLAKE2b-256 b56d245f066f3f6870287d1ec0385d9054a66aaf78a3413d63c5b2e511484fe2

See more details on using hashes here.

File details

Details for the file mecha-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mecha-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 53.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.5 Linux/4.19.128-microsoft-standard

File hashes

Hashes for mecha-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a270e5fb33ab80228983c0aeb558796a24d4795fa51cfbbb451a4a67712ce47c
MD5 968b545ab60767336af7724532d7fc6d
BLAKE2b-256 40a4680c9e316055744a207d6ab2bc31c225b882c2dedf8060ed719b6f9d932c

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