Skip to main content

Minecraft Object Utils

A python library for creating objects that represent blocks, items, and entities from Minecraft Java Edition.

Features

  • Support for multiple versions of vanilla Minecraft
  • Support for modded Minecraft by importing from custom toml files
  • Ensure that block states are valid

Basic Usage

Vanilla Minecraft

The default constructor will reflect objects from the latest version of minecraft. The minecraft namespace is assumed if one is not supplied in the block name.

Basic Example: create a dirt block.

from minecraft_object_utils import MinecraftObjectFactory
mcof = MinecraftObjectFactory()
block1 = mcof.block.create("dirt")  # same result as "minecraft:dirt"
item1 = mcof.item.create("minecraft:egg")  # same result as "egg"
entity1 = mcof.entity.create("chicken")

Example: create blocks and set some properties.

block2 = mcof.block.create("dispenser")
print(block2.get_state("facing"))  # default is "north"
block2.set_state("facing", "east")
print(block2.get_state("facing")) 
block2.set_state("triggered", "very")  # will error, invalid state
block2.set_state("color", "red")  # will error, invalid property

# You can also specify initial block state values with keyword arguments
block3 = mcof.block.create("repeater", facing="south", delay=4)

Modded Minecraft

You can create and import toml files to represent objects from mods.

Example: for Create mod v0.5.0i, make "/your/configs/dir/create-0.5.0i-block.toml" and import:

from minecraft_object_utils import MinecraftObjectFactory, ModInfo
mods = [
    ModInfo("minecraft", "1.19"),
    ModInfo("create", "0.5.0i", "/your/configs/dir"),
]
mcof_mods = MinecraftObjectFactory(mods)
block3 = mcof_mods.block.create("stone")  # assumes "minecraft:stone"
block4 = mcof_mods.block.create("create:chute")

You can also register info to a factory manually. Example:

from minecraft_object_utils import BlockProperty, BlockTraits, MinecraftObjectFactory
cust_f = MinecraftObjectFactory([])
bt1 = BlockTraits("yourmod:yourblock")  # block with no state
bt2 = BlockTraits(
    "othermod:otherblock",
    props=[
        BlockProperty("awesome", False, [True, False]),
        BlockProperty("fakename", "foo", ["foo", "bar", "baz"]),
    ],
)

cust_f.block.register(bt1)
cust_f.block.register(bt2)
block5 = cust_f.block.create("yourmod:yourblock")
block6 = cust_f.block.create("othermod:otherblock")
block6.set_state("awesome", True)

Generating toml files

I generated the toml by running Minecraft out of IntelliJ. I'd like to make a fabric/forge mod that can output these files. For now, some rough code is here: minecraft-registry-dumper

Metadata

Release files for minecraft-object-utils 0.5.0

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

Source distribution (sdist)

Source distribution for minecraft-object-utils 0.5.0
File Size Uploaded Provenance Actions
minecraft_object_utils-0.5.0.tar.gz 35.8 kB Without provenance Details for minecraft_object_utils-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minecraft-object-utils 0.5.0
File Interpreter ABI Platform Actions
minecraft_object_utils-0.5.0-py3-none-any.whl Python 3 none any Details for minecraft_object_utils-0.5.0-py3-none-any.whl

Total release size: 75.4 kB

Release files / minecraft_object_utils-0.5.0.tar.gz

Download URL minecraft_object_utils-0.5.0.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8032fcc52344b1851d35420aa36e9cd1baca03441f22f0dafacdc5ff2f250453
BLAKE2b-256 checksum
How to use checksums
af226e716933f6bf51f2e0c78223a5f385f44d99e82eb6ef133f561e26b70b2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.13 Linux/5.15.0-1041-azure

Release files / minecraft_object_utils-0.5.0-py3-none-any.whl

Download URL minecraft_object_utils-0.5.0-py3-none-any.whl
Size 39.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f01fa424dda08e5a0d1ace54acf3cad2c0d74f93a71f35dfeee82a4f18f4c00
BLAKE2b-256 checksum
How to use checksums
0a2b9a85c5516be28361e3ddb76728889a1ec7bc2614e02514092049c516ea06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.13 Linux/5.15.0-1041-azure

Security for minecraft-object-utils 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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