Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubixdev/rustmatica
A Rust crate for working with Minecraft litematica files
https://github.com/rubixdev/rustmatica
litematica minecraft minecraft-tool nbt rust rust-crate schematic
Last synced: about 2 months ago
JSON representation
A Rust crate for working with Minecraft litematica files
- Host: GitHub
- URL: https://github.com/rubixdev/rustmatica
- Owner: RubixDev
- License: gpl-3.0
- Created: 2022-04-12T18:44:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-12T09:37:27.000Z (8 months ago)
- Last Synced: 2024-10-20T00:26:08.937Z (3 months ago)
- Topics: litematica, minecraft, minecraft-tool, nbt, rust, rust-crate, schematic
- Language: Rust
- Homepage: https://crates.io/crates/rustmatica
- Size: 903 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# rustmatica
[![Crates.io](https://img.shields.io/crates/v/rustmatica)](https://crates.io/crates/rustmatica)
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](https://github.com/RubixDev/rustmatica/tree/main/examples)
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.```rust
use rustmatica::Litematic;
use mcdata::util::UVec3;// 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(UVec3::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:```toml
mcdata = { version = "", features = ["latest", "block-states"] }
```Then you can use the `mcdata::latest::BlockState` type instead:
```rust
use rustmatica::Litematic;
use mcdata::{util::UVec3, latest::BlockState};
use bounded_integer::BoundedU8;let schem: Litematic = Litematic::read_file("test_files/axolotl.litematic")?;
// block has type `BlockState`
let block = schem.regions[0].get_block(UVec3::new(1, 0, 1));
assert_eq!(block, &BlockState::Water {
level: BoundedU8::new(0).unwrap(),
});
# Ok::<(), rustmatica::Error>(())
```