Skip to main content

Parser for Hytale .region.bin files (IndexedStorageFile format)

Project description

Hytale Region Parser

PyPI version Python versions License: MIT

A Python library for parsing Hytale .region.bin files (IndexedStorageFile format).

Overview

This tool parses Hytale world region files to extract and analyze chunk data, including block information, components, containers, and entities. It implements a custom BSON parser compatible with Hytale's codec system and handles zstandard-compressed data blobs.

The code is mostly written by letting Claude Sonnet and Opus analyze the HytaleServer.jar's decompiled code and reimplementing the relevant parts in Python. I mainly wrote this because I wanted to learn about ore distribution, but this might serve others as a starter, too.

There is still a bug regarding parsed entity names, that I haven't been able to figure out.

Features

  • Parse IndexedStorageFile format (.region.bin files)
  • JSON output to file by default with position-keyed block data
  • Folder processing - parse entire directories or universe structures
  • All output files written to current working directory
  • Extract chunk data with block palettes and component information
  • Decode BSON documents using Hytale's codec format
  • Identify and list unique block types across regions
  • Parse item containers (chests, barrels, etc.) with position and capacity
  • Extract block components and entity data
  • Support for zstandard decompression
  • Type hints and dataclasses for clean API
  • Command-line interface and Python API

Installation

From PyPI

pip install hytale-region-parser

From Source

git clone https://github.com/TheMcSebi/hytale-region-parser.git
cd hytale-region-parser
pip install -e .

Development Installation

pip install -e ".[dev]"

Quick Start

Command Line

# Parse single file (writes -2.-3.region.json in current directory)
hytale-region-parser chunks/-2.-3.region.bin

# Parse a "chunks" folder (writes <worldname>.json in current directory)
hytale-region-parser path/to/worldname/chunks/

# Parse a universe folder (writes <worldname>.json for each world in current directory)
hytale-region-parser path/to/universe/worlds/

# Parse a flat folder of region files (writes regions.json in current directory)
hytale-region-parser path/to/region_files/

# Output to stdout instead of file
hytale-region-parser path/to/0.0.region.bin --stdout

# Specify custom output file
hytale-region-parser path/to/0.0.region.bin -o output.json

# Compact JSON (no indentation)
hytale-region-parser path/to/0.0.region.bin --compact

# Suppress progress messages
hytale-region-parser path/to/chunks/ -q

Python API

from pathlib import Path
from hytale_region_parser import RegionFileParser

# Get JSON output (recommended)
with RegionFileParser(Path("0.0.region.bin")) as parser:
    # Get as dictionary
    data = parser.to_dict()
    
    # Or as JSON string
    json_str = parser.to_json(indent=2)
    print(json_str)

# Iterate over chunks for custom processing
with RegionFileParser(Path("0.0.region.bin")) as parser:
    for chunk in parser.iter_chunks():
        print(f"Chunk ({chunk.chunk_x}, {chunk.chunk_z})")
        print(f"  Block types: {len(chunk.block_names)}")
        print(f"  Containers: {len(chunk.containers)}")

# Get a summary of the entire region
with RegionFileParser(Path("0.0.region.bin")) as parser:
    summary = parser.get_summary()
    print(f"Unique block types: {summary['unique_blocks']}")

JSON Output Format

The default output is JSON with world coordinates as keys:

{
  "100,64,200": {
    "name": "Container",
    "components": {
      "container": {
        "capacity": 18,
        "items": [
          {"Id": "Ore_Copper", "Quantity": 4}
        ],
        "allow_viewing": true,
        "custom_name": null
      }
    }
  },
  "150,32,180": {
    "name": "FarmingBlock",
    "components": {
      "FarmingBlock": {
        "SpreadRate": 0.0
      }
    }
  }
}

The coordinates are in world space (chunk_x * 32 + local_x, etc.).

Folder Processing

The CLI supports three folder structures:

All output files are written to the current working directory where the command is executed.

Single File

hytale-region-parser chunks/-2.-3.region.bin
# Output: ./-2.-3.region.json

Chunks Folder

When pointing to a folder named "chunks", the parent folder is used as the world name:

hytale-region-parser path/to/default/chunks/
# Output: ./default.json (merges all region files)

Universe Folder

When pointing to a folder containing world subfolders with "chunks" directories:

hytale-region-parser path/to/universe/worlds/
# Output: ./world1.json
#         ./world2.json
#         (one JSON file per world)

Flat Folder

Any other folder containing .region.bin files:

hytale-region-parser path/to/region_files/
# Output: ./regions.json (merges all region files)

Data Models

ParsedChunkData

The main result type containing all parsed chunk information:

@dataclass
class ParsedChunkData:
    chunk_x: int                              # Chunk X coordinate
    chunk_z: int                              # Chunk Z coordinate
    version: int                              # Data format version
    sections: List[ChunkSectionData]          # 32x32x32 block sections
    block_components: List[BlockComponent]    # Block component data
    containers: List[ItemContainerData]       # Item containers (chests, etc.)
    entities: List[Dict[str, Any]]            # Entity data
    block_names: Set[str]                     # Unique block type names
    raw_components: Dict[str, Any]            # Raw BSON component data

ItemContainerData

Represents storage blocks like chests:

@dataclass
class ItemContainerData:
    position: Tuple[int, int, int]    # Block position
    capacity: int                      # Number of slots
    items: List[Dict[str, Any]]       # Item data in slots
    custom_name: Optional[str]        # Custom container name

File Format

The parser handles the following Hytale data structures:

  • IndexedStorageFile: Container format for region files (32-byte header + index table + segments)
  • Chunk Data: 32x32 column sections containing blocks and metadata
  • Block Components: Special block data (containers, signs, doors, etc.)
  • BSON Documents: Hytale's serialization format for game data

Each region file contains up to 1024 chunks (32×32 grid), compressed with Zstandard.

Development

Running Tests

pytest

Type Checking

mypy src/hytale_region_parser

Linting

ruff check src/hytale_region_parser

Building for PyPI

pip install build twine
python -m build
twine upload dist/*

Output

The parser identifies various block categories including:

  • Rock, Soil, Plant, Wood, Ore
  • Furniture, Metal, Stone, Grass, Tree
  • Water, Lava, Ice, Sand, Brick, Glass
  • Structural elements (Roof, Floor, Stair, Door, Window)
  • Interactive blocks (Chest, Barrel, Crate)
  • And more

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

hytale_region_parser-0.1.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hytale_region_parser-0.1.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file hytale_region_parser-0.1.0.tar.gz.

File metadata

  • Download URL: hytale_region_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for hytale_region_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ca055ae01879bedeb1648d4cb449699dc8e7954453ae7ef4f0bf038a280512c
MD5 d13458cc6899a8a1c294e481a2506857
BLAKE2b-256 895e5efe71111a7e87862b449a2a4f83c5e51d598ebe319afb7ad5d0092c418d

See more details on using hashes here.

File details

Details for the file hytale_region_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hytale_region_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 863df5fccb34ab84d89c67ad4fb0ded40a65baae4600e191a9484c9153798966
MD5 75046816a840540527494dd24d3d5eca
BLAKE2b-256 be4e23d66932007830697a9697720049af2b11a74057a8407c300c8031e269c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page