Create python objects that represent Minecraft blocks, items, and entities.
Project description
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 *
mcof = MinecraftObjectFactory()
block1 = mcof.blocks.create("dirt") # same result as "minecraft:dirt"
Example: create a dispenser, which has powered and facing states.
mcof = MinecraftObjectFactory()
block2 = mcof.blocks.create("dispenser")
block2.get_state('facing') # default is "north"
block2.set_state('powered', True)
block2.set_state('powered', "very") # will error, invalid state
block2.set_state('color', "red") # will error, invalid property
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-blocks.toml" and import:
mods = [
ModInfo("minecraft","1.19.2"),
ModInfo("create","0.5.0i", "/your/configs/dir")
]
mcof = MinecraftObjectFactory(mods)
block3 = mcof.blocks.create("stone") # assumes "minecraft:stone"
block4 = mcof.blocks.create("create:chute")
You can also register block info to the factory manually. Example:
bf = BlockFactory([])
bt1 = BlockTraits("yourmod:yourblock") # block with no state
bt2 = BlockTraits(
"othermod:otherblock",
[
BlockProperty('awesome', False, [True, False]),
BlockProperty('fakename', "foo", ["foo", "bar", "baz"]),
],
)
bf.register(bt1)
bf.register(bt2)
block1 = bf.create("yourmod:yourblock")
block2 = bf.create("othermod:otherblock")
block2.set_state('awesome', True)
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
Built Distribution
Hashes for minecraft_object_utils-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a08f8b6a5dbade035e595f2b809d6b77413d492c8d24446c6264287f08638788 |
|
MD5 | 6d786d254420855a4c9c0c3fa149f266 |
|
BLAKE2b-256 | 81cc995020a355f4b1388f6fc300bded20cd92dfd2d4103581aea5e7a0c3df90 |
Hashes for minecraft_object_utils-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d7f43ddabb17c801dbbc023daa8cf107f2e7c60ce398ee7e39fbe037e6fee1f |
|
MD5 | edb8bdd47d4676d0e66e9eab591c4acb |
|
BLAKE2b-256 | d9cde8e0e1fb9a0cda508d4605f77b11c383ea25ff179e5ab7dcbbd8831ccfc4 |