minecraft-object-utils


Nameminecraft-object-utils JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/BenBenBenB/minecraft-object-utils
SummaryCreate python objects that represent Minecraft blocks, items, and entities.
upload_time2023-09-09 18:42:27
maintainer
docs_urlNone
authorBen Burton
requires_python>=3.8,<4.0
licenseMIT
keywords minecraft
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.
```python
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.
```python
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:
```python
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:
```python
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](https://github.com/BenBenBenB/minecraft-registry-dumper)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/BenBenBenB/minecraft-object-utils",
    "name": "minecraft-object-utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "minecraft",
    "author": "Ben Burton",
    "author_email": "benjaminburtondev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/22/6e716933f6bf51f2e0c78223a5f385f44d99e82eb6ef133f561e26b70b2e/minecraft_object_utils-0.5.0.tar.gz",
    "platform": null,
    "description": "# Minecraft Object Utils\n\n> A python library for creating objects that represent blocks, items, and entities from Minecraft Java Edition.\n\n**Features**\n- Support for multiple versions of vanilla Minecraft\n- Support for modded Minecraft by importing from custom toml files\n- Ensure that block states are valid\n\n## Basic Usage\n\n### Vanilla Minecraft\nThe 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.\n\nBasic Example: create a dirt block.\n```python\nfrom minecraft_object_utils import MinecraftObjectFactory\nmcof = MinecraftObjectFactory()\nblock1 = mcof.block.create(\"dirt\")  # same result as \"minecraft:dirt\"\nitem1 = mcof.item.create(\"minecraft:egg\")  # same result as \"egg\"\nentity1 = mcof.entity.create(\"chicken\")\n```\n\nExample: create blocks and set some properties.\n```python\nblock2 = mcof.block.create(\"dispenser\")\nprint(block2.get_state(\"facing\"))  # default is \"north\"\nblock2.set_state(\"facing\", \"east\")\nprint(block2.get_state(\"facing\")) \nblock2.set_state(\"triggered\", \"very\")  # will error, invalid state\nblock2.set_state(\"color\", \"red\")  # will error, invalid property\n\n# You can also specify initial block state values with keyword arguments\nblock3 = mcof.block.create(\"repeater\", facing=\"south\", delay=4)\n```\n\n### Modded Minecraft\nYou can create and import toml files to represent objects from mods.\n\nExample: for Create mod v0.5.0i, make \"/your/configs/dir/create-0.5.0i-block.toml\" and import:\n```python\nfrom minecraft_object_utils import MinecraftObjectFactory, ModInfo\nmods = [\n    ModInfo(\"minecraft\", \"1.19\"),\n    ModInfo(\"create\", \"0.5.0i\", \"/your/configs/dir\"),\n]\nmcof_mods = MinecraftObjectFactory(mods)\nblock3 = mcof_mods.block.create(\"stone\")  # assumes \"minecraft:stone\"\nblock4 = mcof_mods.block.create(\"create:chute\")\n```\n\nYou can also register info to a factory manually. \nExample:\n```python\nfrom minecraft_object_utils import BlockProperty, BlockTraits, MinecraftObjectFactory\ncust_f = MinecraftObjectFactory([])\nbt1 = BlockTraits(\"yourmod:yourblock\")  # block with no state\nbt2 = BlockTraits(\n    \"othermod:otherblock\",\n    props=[\n        BlockProperty(\"awesome\", False, [True, False]),\n        BlockProperty(\"fakename\", \"foo\", [\"foo\", \"bar\", \"baz\"]),\n    ],\n)\n\ncust_f.block.register(bt1)\ncust_f.block.register(bt2)\nblock5 = cust_f.block.create(\"yourmod:yourblock\")\nblock6 = cust_f.block.create(\"othermod:otherblock\")\nblock6.set_state(\"awesome\", True)\n```\n\n### Generating toml files\nI 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](https://github.com/BenBenBenB/minecraft-registry-dumper)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create python objects that represent Minecraft blocks, items, and entities.",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/BenBenBenB/minecraft-object-utils",
        "Repository": "https://github.com/BenBenBenB/minecraft-object-utils"
    },
    "split_keywords": [
        "minecraft"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a2b9a85c5516be28361e3ddb76728889a1ec7bc2614e02514092049c516ea06",
                "md5": "39159a55aca3b1a536ff2a919bee4f8a",
                "sha256": "3f01fa424dda08e5a0d1ace54acf3cad2c0d74f93a71f35dfeee82a4f18f4c00"
            },
            "downloads": -1,
            "filename": "minecraft_object_utils-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39159a55aca3b1a536ff2a919bee4f8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 39568,
            "upload_time": "2023-09-09T18:42:26",
            "upload_time_iso_8601": "2023-09-09T18:42:26.111268Z",
            "url": "https://files.pythonhosted.org/packages/0a/2b/9a85c5516be28361e3ddb76728889a1ec7bc2614e02514092049c516ea06/minecraft_object_utils-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af226e716933f6bf51f2e0c78223a5f385f44d99e82eb6ef133f561e26b70b2e",
                "md5": "22db604ea2bfaeeda8aadcb4d8371720",
                "sha256": "8032fcc52344b1851d35420aa36e9cd1baca03441f22f0dafacdc5ff2f250453"
            },
            "downloads": -1,
            "filename": "minecraft_object_utils-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "22db604ea2bfaeeda8aadcb4d8371720",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 35785,
            "upload_time": "2023-09-09T18:42:27",
            "upload_time_iso_8601": "2023-09-09T18:42:27.159442Z",
            "url": "https://files.pythonhosted.org/packages/af/22/6e716933f6bf51f2e0c78223a5f385f44d99e82eb6ef133f561e26b70b2e/minecraft_object_utils-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-09 18:42:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "BenBenBenB",
    "github_project": "minecraft-object-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "minecraft-object-utils"
}
        
Elapsed time: 0.11928s