Create, read, and edit Minecraft NBT structure files.
Project description
NBTStructureUtils
A python library to create and edit NBT structure files for Minecraft.
This has been tested with Minecraft 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
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:
Edit blocks
Basic Example: create a 5x5x5 hollow cube of stone and save to file:
from nbt_structure_utils import NBTStructure, Vector, Cuboid, BlockData
nbtstructure = NBTStructure()
c1, c2 = Vector(0, 0, 0), Vector(4, 4, 4)
nbtstructure.fill_hollow(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:
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:
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")
Project details
Release history Release notifications | RSS feed
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 nbt_structure_utils-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 757962cfdcb4bff33e4ccc34a8aa05ef0fd46e4185f0e2e80018b0373899c53e |
|
MD5 | 5667826d27fc4026d759bfed0cad10c8 |
|
BLAKE2b-256 | f4b294d24920df7aa032726e96ca32eb85b482998420e5f4c4267c2fdc95ef54 |
Hashes for nbt_structure_utils-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65b18e27980f8ba2f4579d615a35842fffeced6d586c5b42e439b7ad0072f2e6 |
|
MD5 | ac31ac56eb067ef8aebe5d831d9ef794 |
|
BLAKE2b-256 | 49122609746e9f8243fcf754f6ab989befcd7f5fa5e8e79613d5f36743d7ed30 |