Skip to main content

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

Release files for mecha-custom-components 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mecha-custom-components 0.0.3
File Size Uploaded
mecha_custom_components-0.0.3.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mecha-custom-components 0.0.3
File Interpreter ABI Platform
mecha_custom_components-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / mecha_custom_components-0.0.3.tar.gz

Download URL mecha_custom_components-0.0.3.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cb0a7010579348db5e3c08be6d1b775b8e666f91beaff05b7cf57fa7b2b8c3b1
BLAKE2b-256 checksum
How to use checksums
84ca717778842dbf6d2ad4741e99840ef908b954d343b28c799b01a124d7f772
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / mecha_custom_components-0.0.3-py3-none-any.whl

Download URL mecha_custom_components-0.0.3-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36073666759ffecb6c3781ce7304c4a7a79baf8a64e446834affef36ac0d0f6d
BLAKE2b-256 checksum
How to use checksums
8e6d0b72d35ad9930634d9cfe4a82b285aafab0a385b21306dc58a08bc56cdbc
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page