Skip to content

Converts Java .nbt files to Bedrock .mcstructure files

License

Notifications You must be signed in to change notification settings

JaylyDev/nbt-to-mcstructure

Repository files navigation

nbt-to-mcstructure

Converts Java .nbt files to Bedrock .mcstructure files

demo_video

Introduction

This program is a port of Structure Editor originally made by MCBE Essentials in Python 3.

The reason this program is built in Python is because:

  • JavaScript has a limit on the size of what Buffer and array can allocate in the engine unlike Python.
  • Structure templates generated in their structure editor does not work in Minecraft, because Minecraft requires the "block_indices" field's arrays need to both be the same size.

Usage

  1. Install required dependencies via:

    pip install -r requirements.txt
    
  2. To convert .nbt files to .mcstructure, put your Java nbt files in the structures folder.

  3. Run __main__.py, the program converts all java structures in the structures folder to the bedrock structure format, and they should be generated in structures folder.

⚠️Make sure your computer has enough memory and spaces on disk to convert large NBT files!

Regolith Filter

This converter is available as a Regolith filter as well. The filter allows you to place your .nbt structure files straight into the packs/BP/structures folder which will be compiled into the .mcstructure format.

How It Works

The filter:

  • Converts .nbt structure files into .mcstructure format.
  • Removes the original .nbt files in the compiled version to keep your project clean.

Enabling the Filter

Add the following to your Regolith filter definitions to enable the filter:

"nbt-to-mcstructure": {"url": "github.com/JaylyDev/nbt-to-mcstructure", "version": "HEAD"}

Configuration

Once installed, the filter generates a settings.json file located in data/nbt-to-mcstructure/. This file allows you to customize block mapping, either by using vanilla overwrites or defining a custom namespace.

Example settings.json

{
    "block_mapping": [
        {
            "structure_id": "add_your_structure_id_here", // Matches your file name (excluding the file suffix).
            "mapping": {
                "minecraft:dirt": "namespace:custom_dirt",
                "minecraft:stone": "namespace:custom_stone"
            }
        },
        {
            "structure_id": "add_another_structure_id_here",
            "mapping": {
                "minecraft:diamond_block": "namespace:custom_diamond_block",
                "minecraft:iron_ore": "namespace:custom_iron_ore"
            }
        }
    ]
}

Using Wildcards

Block mapping supports wildcards to simplify configurations. For example, instead of specifying mappings for each structure individually:

{
    "block_mapping": [
        {"structure_id": "oak_extra_small_1", "mapping": {"minecraft:oak_log": "namespace:custom_oak_log"}},
        {"structure_id": "oak_extra_small_2", "mapping": {"minecraft:oak_log": "namespace:custom_oak_log"}},
        {"structure_id": "oak_extra_small_3", "mapping": {"minecraft:oak_log": "namespace:custom_oak_log"}},
        {"structure_id": "oak_extra_small_4", "mapping": {"minecraft:oak_log": "namespace:custom_oak_log"}},
        {"structure_id": "oak_extra_small_5", "mapping": {"minecraft:oak_log": "namespace:custom_oak_log"}}
    ]
}

You can use a wildcard to reduce redundancy:

{
    "block_mapping": [
        {
            "structure_id": "oak_extra_small_*",
            "mapping": {
                "minecraft:oak_log": "namespace:custom_oak_log"
            }
        }
    ]
}

This approach saves space and simplifies configurations for large projects involving multiple similar structures, such as trees, houses, or castles.

Contributing

We welcome contributions to keep this converter up-to-date and efficient. For inquiries or to collaborate:

  • JaylyDev: Contact regarding the core program.
  • ThijsHankelMC: Contact regarding the Regolith Filter.

Discord IDs:

  • jaylymc
  • thijsmc