rustmatica

Crates.iorustmatica
lib.rsrustmatica
version
sourcesrc
created_at2023-03-03 13:52:51.49013
updated_at2025-02-04 20:34:03.528576
descriptionA Rust library for reading, editing, and writing Minecraft litematic files
homepage
repositoryhttps://github.com/RubixDev/rustmatica
max_upload_size
id799772
Cargo.toml error:TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Silas Groh (RubixDev)

documentation

README

rustmatica

Crates.io

A rust crate for working with Minecraft litematica files.

Overview

The two main types of this crate are [Litematic] and [Region]. See their documentation for more info.

The examples directory contains a few basic examples for how to use this crate.

Usage with [mcdata]

rustmatica is tightly coupled with [mcdata] and makes use of its traits for block states, entities, and block entities. By default, schematics will use [mcdata]s "generic" types which store most of their data using [fastnbt::Value]s.

use rustmatica::Litematic;
use mcdata::util::BlockPos;

// type must be declared explicitly for Rust to use the default generics
let schem: Litematic = Litematic::read_file("test_files/axolotl.litematic")?;

// block has type `mcdata::GenericBlockState`
let block = schem.regions[0].get_block(BlockPos::new(1, 0, 1));
assert_eq!(block.name, "minecraft:water");
// properties aren't typed
assert_eq!(block.properties["level"], "0");
# Ok::<(), rustmatica::Error>(())

But [mcdata] also offers more concrete types when enabling certain cargo features. To use these, add a custom dependency on [mcdata] similar to this:

mcdata = { version = "<version>", features = ["latest", "block-states"] }

Then you can use the mcdata::latest::BlockState type instead:

use rustmatica::Litematic;
use mcdata::{util::BlockPos, latest::BlockState};
use bounded_integer::BoundedU8;

let schem: Litematic<BlockState> = Litematic::read_file("test_files/axolotl.litematic")?;

// block has type `BlockState`
let block = schem.regions[0].get_block(BlockPos::new(1, 0, 1));
assert_eq!(block, &BlockState::Water {
    level: BoundedU8::new(0).unwrap(),
});
# Ok::<(), rustmatica::Error>(())
Commit count: 94

cargo fmt