Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
28dcda6
Implement support for legacy .schematic format
Larson-Logan Dec 5, 2025
660fb94
Finalize .schematic support and refactor
Larson-Logan Dec 5, 2025
7989903
Fix README formatting and lint errors
Larson-Logan Dec 5, 2025
de57834
Exclude build artifacts and document build process
Larson-Logan Dec 6, 2025
9df7e79
Remove build artifacts from version control
Larson-Logan Dec 6, 2025
e10d375
Add support for preserving .bp thumbnails
Larson-Logan Dec 6, 2025
05d832a
Bump version to 1.3.0
Larson-Logan Dec 6, 2025
849bad1
Revert version to 1.2.5
Larson-Logan Dec 6, 2025
5f46f4e
Bump version to 1.3.0 for release
Larson-Logan Dec 6, 2025
6750309
Refactor file scanning logic in convert_all.py
Larson-Logan Dec 6, 2025
00ae6b2
Add instructions for using the batch converter tool
Larson-Logan Dec 6, 2025
65253eb
Update README with new version number
Larson-Logan Dec 6, 2025
9b87dcc
Update README.md to reflect version 1.3.0
Larson-Logan Dec 6, 2025
3b75ee2
Refactor NBT handling for improved type safety and error handling
Larson-Logan Dec 6, 2025
31df488
Fix NBT schematic writing and size restrictions
Larson-Logan Dec 6, 2025
a77305f
Improve NBT reading and conversion exception handling
Larson-Logan Dec 6, 2025
015e07c
Simplify block string conversion in NBTUtil
Larson-Logan Dec 6, 2025
2fb04c5
Refactor: Move build scripts and update README
Larson-Logan Dec 6, 2025
cc572d5
Add Gradle build command to README
Larson-Logan Dec 6, 2025
a7bb5e9
Enhance README with new features and clarity
Larson-Logan Dec 6, 2025
52877cd
feat: Add procedural thumbnail generation for .bp format
Larson-Logan Dec 6, 2025
5dedded
feat: Allow specifying output format in convert_all.py
Larson-Logan Dec 6, 2025
fa0148a
Update README and build version to 1.3.1
Larson-Logan Dec 6, 2025
9b61437
Update README to reflect new SchemConvert capabilities
Larson-Logan Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ bin/
# Ignore Gradle project-specific cache directory
.gradle


# Ignore Gradle build output directory
build

### Python Build Artifacts ###
build_artifacts/
*.spec
98 changes: 92 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,96 @@
# SchemConvert
A lightweight tool to convert between different Minecraft schematic formats.

**This tool requires Java 21 or later to run. If you have trouble running it, updating to a newer version of Java will likely fix the issue.**
A lightweight and powerful tool to convert between different Minecraft schematic formats.

**This tool requires Java 21 or later.**

## Supported Formats
- `.nbt` - Used by vanilla structure blocks
- `.schem` - Used by many community programs, including WorldEdit and MCEdit
- `.litematic` - Used by Litematica
- `.bp` - Used by Axiom for blueprints

- `.nbt`: Vanilla Minecraft Structure blocks.
- `.schem`: Modern Sponge schematic format (used by WorldEdit, MCEdit Unified).
- `.litematic`: Litematica mod format.
- `.bp`: Axiom mod blueprints.
- `.schematic`: Legacy MCEdit/WorldEdit format (supports reading & writing).

## Features

- **Cross-Format Conversion**: Convert freely between any of the supported formats.
- **Legacy Support**: Full support for reading and writing the legacy `.schematic` format.
- **Batch Conversion**: Recursively convert entire folders of schematics using the Python helper script.
- **Procedural Texture Generation**: Generates high‑quality 16×16 pixel‑art textures (logs, planks, bricks, leaves, etc.) internally, so previews work without an external `textures/` folder.
- **External Textures (Optional)**: Place a `textures/block/` directory next to the JAR to override generated textures with custom assets.
- **Thumbnail Preservation**: Preserves embedded preview images when converting Axiom `.bp` files.
- **CLI & GUI**: Run from the command line for automation, or launch without arguments for a graphical interface.

## Usage

### Command Line Interface (CLI)

```bash
java -jar build/libs/SchemConvert-1.3.1-all.jar -input <input_file> -format <output_format> -output <output_file>
```

**Arguments:**

- `-input`: Path to the source file to convert.
- `-format` (optional): Desired output format/extension (e.g., `schem`, `litematic`, `bp`, `nbt`, `schematic`). If omitted, inferred from the output filename.
- `-output` (optional): Path for the converted file. If omitted, saves to the same directory with the new extension.

### External Textures (Optional)

You can optionally place a `textures/block/` folder next to the executable to use your own resource‑pack textures for the previews. If omitted, the tool will automatically generate high‑quality procedural textures.

## Building from Source

To build the project yourself, clone the repository and run the automated release script:

```bash
./scripts/build_release.bat
```

Alternatively, you can run the Gradle build command directly:

```bash
./scripts/gradlew build
```

The resulting JAR is located at `build/libs/SchemConvert-1.3.1-all.jar`.

## Batch Converter Tool

The project includes a Python helper script to mass‑convert files, which can be built into a standalone executable.

### Building the Executable

**Requirements:**

- Python installed
- `pyinstaller` installed (`pip install pyinstaller`)

To build the executable, run the provided batch script:

```batch
./scripts/build_executable.bat
```

This will create `convert_all.exe` inside `build_artifacts/dist/`.

### Batch Tool Usage

```bash
convert_all.exe -j <path_to_jar> -d <root_directory> -o <output_directory> -f <target_format>
```

- `-j`, `--jar`: Path to the `SchemConvert` JAR file (required).
- `-d`, `--directory`: Root directory to scan for files (default: current directory).
- `-o`, `--output`: Directory to save converted files (default: same as input).
- `-e`, `--extensions`: Comma‑separated list of extensions to convert (default: `.schem,.schematic,.nbt,.dp`).
- `-f`, `--format`: Target output format/extension (e.g., `bp`, `schem`, `schematic`).

**Example:**

```bash
convert_all.exe -j SchemConvert-1.3.1-all.jar -d ./my_schematics -o ./converted_blueprints -f bp
```

---
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'pitheguy.schemconvert'
version = '1.2.5'
version = '1.3.1'

repositories {
mavenCentral()
Expand All @@ -14,6 +14,7 @@ repositories {
dependencies {
implementation 'com.google.guava:guava:latest.release'
implementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
implementation 'com.google.code.gson:gson:2.10.1'
}

java {
Expand Down
23 changes: 23 additions & 0 deletions scripts/build_executable.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off
pushd "%~dp0"
if not exist "convert_all.py" (
echo Error: convert_all.py not found!
exit /b 1
)

if not exist "..\build_artifacts" mkdir ..\build_artifacts

echo Building executable...
pyinstaller --onefile --clean ^
--distpath ../build_artifacts/dist ^
--workpath ../build_artifacts/build ^
--specpath ../build_artifacts ^
--name convert_all ^
convert_all.py

if %ERRORLEVEL% EQU 0 (
echo Build successful! Executable is in ..\build_artifacts\dist\convert_all.exe
) else (
echo Build failed!
)
popd
37 changes: 37 additions & 0 deletions scripts/build_release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@echo off

echo ==========================================
echo Starting SchemConvert Build Process
echo ==========================================

REM Ensure we are in the project root (parent of this script)
pushd "%~dp0.."

REM --- Step 1: Build the Java JAR ---
echo.
echo [1/3] Building Java JAR with Gradle...
echo.
call scripts\gradlew.bat clean shadowJar
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Gradle build failed!
exit /b 1
)

REM --- Step 2: Build the Python Executable ---
echo.
echo [2/3] Building Python Executable...
echo.
call scripts\build_executable.bat
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Python executable build failed!
exit /b 1
)

echo ==========================================
echo Build Complete!
echo ==========================================
echo Java JAR location: build\libs\SchemConvert-1.3.0-all.jar
echo Python EXE location: build_artifacts\dist\convert_all.exe

popd
pause
176 changes: 176 additions & 0 deletions scripts/convert_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
"""
usage: convert_all.py [-h] -j JAR [-d DIRECTORY] [-o OUTPUT] [-e EXTENSIONS]

Mass convert schematic files using SchemConvert JAR.

options:
-h, --help show this help message and exit
-j JAR, --jar JAR The path/name of the converter JAR file (e.g., SchemConvert-1.2.5-all.jar)
-d DIRECTORY, --directory DIRECTORY
The root directory to scan for input files (default: current directory)
-o OUTPUT, --output OUTPUT
The directory to save the output .bp files (default: same as input file directory)
-e EXTENSIONS, --extensions EXTENSIONS
Comma-separated list of accepted input file extensions (e.g., .schem,.nbt)
"""

import subprocess
import argparse
from pathlib import Path

def scan_and_convert(directory, jar_name, extensions, output_dir, output_format):
"""
Scans a directory and subdirectories for accepted file types and initiates conversion for each.

Args:
directory (str): The root directory to start scanning from.
jar_name (str): The name/path of the JAR executable.
extensions (list): A list of accepted file extensions (e.g., ['.schem', '.nbt']).
output_dir (str): The specified output directory path.
output_format (str): The target format extension (e.g., 'schem', 'bp').
"""

# Ensure extensions are correctly formatted with leading dots for comparison
# Use a set for faster lookup
formatted_extensions = {f".{ext.strip('.')}".lower() for ext in extensions}

# Ensure output format has no leading dot for the CLI arg, but we need dot for filename
format_ext = f".{output_format.strip('.')}"
format_arg = output_format.strip('.')

source_path = Path(directory)
if not source_path.exists():
print(f"Directory not found: {directory}")
return

found_files = []

# use rglob("*") to recursively check all subfiles and subfolders
for file_path in source_path.rglob("*"):
if file_path.is_file() and file_path.suffix.lower() in formatted_extensions:
found_files.append(file_path)

if not found_files:
# Provide feedback if no relevant files are found
print(f"No files found in '{directory}' with extensions {list(formatted_extensions)}.")
return

print(f"Found {len(found_files)} files to convert using {jar_name}.")
# Iterate through all found files and call the conversion function
for file_path in found_files:
convert_file(jar_name, file_path, output_dir, format_ext, format_arg)


def convert_file(jar_name, input_file_path, output_directory, output_extension, output_format):
"""
Runs the java command for a single file conversion using the specified JAR.

Args:
jar_name (str): The name/path of the JAR executable.
input_file_path (Path): The full path to the input file to convert.
output_directory (str): The specified output directory path.
output_extension (str): The extension to use for the output file (e.g., .bp).
output_format (str): The format argument for the JAR (e.g., bp).
"""
# Create the output filename by taking the input filename's base name (stem) and adding the new extension
output_filename = Path(input_file_path).stem + output_extension

# Determine the full output path
if output_directory == ".":
# If output directory is '.', save the output file in the same directory as the input file
output_file_path = Path(input_file_path).parent / output_filename
else:
# Otherwise, combine the absolute output directory path with the new filename
# Ensure the output directory exists before trying to write a file there
Path(output_directory).mkdir(parents=True, exist_ok=True)
output_file_path = Path(output_directory) / output_filename

# Build the complete command as a list of strings, which is safer than a single string
# when using subprocess (avoids shell injection issues and handles spaces in paths better)
command = [
"java", # The java executable
"-jar", # Flag to run an executable JAR file
jar_name, # The path to the converter JAR
"-input", # The input flag expected by the JAR tool
str(input_file_path), # The full path of the input file
"-output", # The output flag expected by the JAR tool
str(output_file_path), # The full path of the desired output file
"-format",
output_format
]

print(f"Converting: {input_file_path}")
print(f"Output to: {output_file_path}")

try:
# Execute the command using subprocess.run
# check=True: Raises an exception if the command returns a non-zero exit code (failure)
# capture_output=True: Captures stdout and stderr
# text=True: Decodes stdout/stderr as strings
result = subprocess.run(command, check=True, capture_output=True, text=True)
print("Conversion successful!")
# print(result.stdout) # Uncomment to see the raw output from the Java tool
except subprocess.CalledProcessError as e:
# Handle errors where the Java tool failed its conversion
print(f"Conversion failed for {input_file_path}:")
print(e.stderr)
except FileNotFoundError as e:
# Handle fundamental errors like 'java' command not found or the JAR file not existing
print(f"Error executing command: {e}")
print("Ensure 'java' is in your system's PATH and the JAR file path is correct.")
print("-" * 40) # Print a separator for readability


if __name__ == "__main__":
# This block runs only when the script is executed directly, not when imported as a module

# Initialize the argument parser with a description
parser = argparse.ArgumentParser(description="Mass convert schematic files using SchemConvert JAR.")

# Define the command line arguments
parser.add_argument(
"-j", "--jar",
type=str,
required=True, # This argument is mandatory
help="The path/name of the converter JAR file (e.g., SchemConvert-1.2.5-all.jar)"
)
parser.add_argument(
"-d", "--directory",
type=str,
default=".", # Default value is the current directory
help="The root directory to scan for input files (default: current directory)"
)
parser.add_argument(
"-o", "--output",
type=str,
default=".",
help="The directory to save the output files (default: same as input file directory)"
)
parser.add_argument(
"-e", "--extensions",
type=str,
# Default list of accepted input file extensions
default=".schem,.schematic,.nbt,.bp,.litematic",
help="Comma-separated list of accepted input file extensions (e.g., .schem,.nbt)"
)
parser.add_argument(
"-f", "--format",
type=str,
required=True,
help="The target output format/extension (e.g., bp, schem, schematic)"
)

# Parse the arguments provided by the user in the command line
args = parser.parse_args()

# Split the comma-separated extensions string from the arguments into a Python list
extensions_list = [ext.strip() for ext in args.extensions.split(',')]

# Call the main scanning and conversion function with the parsed arguments
scan_and_convert(
directory=args.directory,
jar_name=args.jar,
extensions=extensions_list,
output_dir=args.output,
output_format=args.format
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading