Skip to main content

A library to easily extend your Mecha/Bolt code with custom components

Project description

Mecha Custom Components

GitHub Actions PyPI PyPI - Python Version Code style: black

A library to easily extend your Mecha/Bolt code with custom components

Introduction

This package provides an easy way to create your own custom components for mcfunction, using the Beet/Mecha ecosystem.

Features

  • Extensible component registry

Example Usage

Extracted from here

Beet Plugin

from beet import Context
from nbtlib import Base, Compound
from mecha_custom_components import CustomComponentRegistry

def simple_component(properties: Base, components: dict[str, Base]):
    if not isinstance(properties, Compound):
        raise Exception("'example:simple' expects a compound!")

    custom_data = components.setdefault("minecraft:custom_data", Compound({}))

    if not isinstance(custom_data, Compound):
        raise Exception("Existing custom_data was not a compound!")


    custom_data.merge({"foo": properties["value"]})

    return components

def beet_default(ctx: Context):
    registry = ctx.inject(CustomComponentRegistry)
    registry.extend("example:foo", simple_component)

Bolt code

give @s stick[example:foo={value: 1}]

When compiled becomes:

give @s stick[minecraft:custom_data={foo: 1}]

More examples can be found in the examples folder.

Installation

The package can be installed with pip.

$ pip install mecha-custom-components

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

mecha_custom_components-0.0.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

mecha_custom_components-0.0.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file mecha_custom_components-0.0.3.tar.gz.

File metadata

  • Download URL: mecha_custom_components-0.0.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.0 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.3.0 tqdm/4.67.1 importlib-metadata/8.6.1 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.11

File hashes

Hashes for mecha_custom_components-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cb0a7010579348db5e3c08be6d1b775b8e666f91beaff05b7cf57fa7b2b8c3b1
MD5 e74afa4fa535a76ec96c8b930edc74b4
BLAKE2b-256 84ca717778842dbf6d2ad4741e99840ef908b954d343b28c799b01a124d7f772

See more details on using hashes here.

File details

Details for the file mecha_custom_components-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: mecha_custom_components-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.0 readme-renderer/44.0 requests/2.32.3 requests-toolbelt/1.0.0 urllib3/2.3.0 tqdm/4.67.1 importlib-metadata/8.6.1 keyring/25.6.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.11

File hashes

Hashes for mecha_custom_components-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36073666759ffecb6c3781ce7304c4a7a79baf8a64e446834affef36ac0d0f6d
MD5 816291c24fb12622d8b21d5633a68330
BLAKE2b-256 8e6d0b72d35ad9930634d9cfe4a82b285aafab0a385b21306dc58a08bc56cdbc

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