nbt-structure-utils


Namenbt-structure-utils JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/BenBenBenB/nbt-structure-utils
SummaryCreate, read, and edit Minecraft NBT structure files.
upload_time2023-04-28 05:01:17
maintainer
docs_urlNone
authorBen Burton
requires_python>=3.8,<4.0
licenseMIT
keywords minecraft nbt-structure nbt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NBT Structure Utils

> A python library to create and edit NBT structure files for Minecraft.

This has been tested with Minecraft Java, version 1.19.3.

**Features**

- Create, read, and edit NBT structure files.
- Methods inspired by Minecraft's fill, setblock, and clone commands.
- Edit the state, inventory, and NBT data of blocks.
- Special classes to help fill Cuboids and draw straight lines.

## Basic Usage
See class docstrings for finer details and lists of methods.

### Minecraft NBT Structure
This library creates .nbt files that can be placed in minecraft worlds. with a Structure Block or structure command. 

See the minecraft wiki for details on each:
- [Structure Block](https://minecraft.fandom.com/wiki/Structure_Block)
- [structure Command](https://minecraft.fandom.com/wiki/Commands/structure)


### Edit blocks
Basic Example: create a 5x5x5 cube of stone and save to file:
```python
from nbt_structure_utils import NBTStructure, Vector, Cuboid, BlockData
nbtstructure = NBTStructure()
c1, c2 = Vector(0, 0, 0), Vector(4, 4, 4)
nbtstructure.fill(Cuboid(c1, c2), BlockData("stone"))
nbtstructure.get_nbt().write_file(filename="path/to/output/hollow_box.nbt")
```

### Read and Edit 
You can load and edit NBT structures created by this library or by Minecraft. All or part of a structure can also be cloned into other structures.

Example: Load from disk and mirror the structure to be upside down:
```python
from nbt_structure_utils import NBTStructure, Vector
nbtstructure = NBTStructure("path/to/existing_structure.nbt")
nbtstructure.reflect(Vector(None,0,None))
nbtstructure.get_nbt().write_file(filename="path/to/output/structure_flipped.nbt")
```

### Edit inventories
Create an Inventory and save it to desired blocks.

Example: Create a dropper with an enchanted wooden sword in the 5th slot:
```python
from nbt_structure_utils import NBTStructure, Vector, BlockData, Inventory, Enchantment
structure = NBTStructure()
inv_block_info = BlockData("dropper",[("facing","up")])
enchants = [Enchantment("sweeping", 3)]
inv = Inventory([ItemStack("wooden_sword", 1, 4, 0, enchants, None)])
structure.set_block(Vector(0, 0, 0), inv_block_info, inv, None)
nbtstructure.get_nbt().write_file(filename="path/to/output/sword_dropper.nbt")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/BenBenBenB/nbt-structure-utils",
    "name": "nbt-structure-utils",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "minecraft,nbt-structure,nbt",
    "author": "Ben Burton",
    "author_email": "benjaminburtondev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e8/32/217be61362bbaace20f6c61a3cffab74b4c09daff773d98b64c1c7009bfe/nbt_structure_utils-0.3.0.tar.gz",
    "platform": null,
    "description": "# NBT Structure Utils\n\n> A python library to create and edit NBT structure files for Minecraft.\n\nThis has been tested with Minecraft Java, version 1.19.3.\n\n**Features**\n\n- Create, read, and edit NBT structure files.\n- Methods inspired by Minecraft's fill, setblock, and clone commands.\n- Edit the state, inventory, and NBT data of blocks.\n- Special classes to help fill Cuboids and draw straight lines.\n\n## Basic Usage\nSee class docstrings for finer details and lists of methods.\n\n### Minecraft NBT Structure\nThis library creates .nbt files that can be placed in minecraft worlds. with a Structure Block or structure command. \n\nSee the minecraft wiki for details on each:\n- [Structure Block](https://minecraft.fandom.com/wiki/Structure_Block)\n- [structure Command](https://minecraft.fandom.com/wiki/Commands/structure)\n\n\n### Edit blocks\nBasic Example: create a 5x5x5 cube of stone and save to file:\n```python\nfrom nbt_structure_utils import NBTStructure, Vector, Cuboid, BlockData\nnbtstructure = NBTStructure()\nc1, c2 = Vector(0, 0, 0), Vector(4, 4, 4)\nnbtstructure.fill(Cuboid(c1, c2), BlockData(\"stone\"))\nnbtstructure.get_nbt().write_file(filename=\"path/to/output/hollow_box.nbt\")\n```\n\n### Read and Edit \nYou can load and edit NBT structures created by this library or by Minecraft. All or part of a structure can also be cloned into other structures.\n\nExample: Load from disk and mirror the structure to be upside down:\n```python\nfrom nbt_structure_utils import NBTStructure, Vector\nnbtstructure = NBTStructure(\"path/to/existing_structure.nbt\")\nnbtstructure.reflect(Vector(None,0,None))\nnbtstructure.get_nbt().write_file(filename=\"path/to/output/structure_flipped.nbt\")\n```\n\n### Edit inventories\nCreate an Inventory and save it to desired blocks.\n\nExample: Create a dropper with an enchanted wooden sword in the 5th slot:\n```python\nfrom nbt_structure_utils import NBTStructure, Vector, BlockData, Inventory, Enchantment\nstructure = NBTStructure()\ninv_block_info = BlockData(\"dropper\",[(\"facing\",\"up\")])\nenchants = [Enchantment(\"sweeping\", 3)]\ninv = Inventory([ItemStack(\"wooden_sword\", 1, 4, 0, enchants, None)])\nstructure.set_block(Vector(0, 0, 0), inv_block_info, inv, None)\nnbtstructure.get_nbt().write_file(filename=\"path/to/output/sword_dropper.nbt\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create, read, and edit Minecraft NBT structure files.",
    "version": "0.3.0",
    "split_keywords": [
        "minecraft",
        "nbt-structure",
        "nbt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "715e59e3bec47479c7043a45cf3971c26ad12a7e3f7542e0d2f024aba6bd239e",
                "md5": "9391f2f598c0b7c5fb6fd0721fd594a4",
                "sha256": "43912838c1a1dde9ee68eaa3a9c49058ed65408f800197563686995c0efdebff"
            },
            "downloads": -1,
            "filename": "nbt_structure_utils-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9391f2f598c0b7c5fb6fd0721fd594a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 19348,
            "upload_time": "2023-04-28T05:01:15",
            "upload_time_iso_8601": "2023-04-28T05:01:15.164460Z",
            "url": "https://files.pythonhosted.org/packages/71/5e/59e3bec47479c7043a45cf3971c26ad12a7e3f7542e0d2f024aba6bd239e/nbt_structure_utils-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e832217be61362bbaace20f6c61a3cffab74b4c09daff773d98b64c1c7009bfe",
                "md5": "174a07e31dc11249f0396c5d29f16947",
                "sha256": "93dea88949affe83529904f9fa521a67bf551155dc3ce3b4106991a83cdbc0cd"
            },
            "downloads": -1,
            "filename": "nbt_structure_utils-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "174a07e31dc11249f0396c5d29f16947",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 17229,
            "upload_time": "2023-04-28T05:01:17",
            "upload_time_iso_8601": "2023-04-28T05:01:17.307735Z",
            "url": "https://files.pythonhosted.org/packages/e8/32/217be61362bbaace20f6c61a3cffab74b4c09daff773d98b64c1c7009bfe/nbt_structure_utils-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-28 05:01:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "BenBenBenB",
    "github_project": "nbt-structure-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nbt-structure-utils"
}
        
Elapsed time: 1.38205s