Region file format storage for chunks
Add this to your Cargo.toml
:
toml
[dependencies]
anvil-region = "0.3"
```rust use anvil_region::AnvilChunkProvider;
let chunk_provider = AnvilChunkProvider::new("test/region");
let chunkcompoundtag = chunkprovider.loadchunk(4, 2).unwrap(); let levelcompoundtag = chunkcompoundtag.getcompoundtag("Level").unwrap();
asserteq!(levelcompoundtag.geti32("xPos").unwrap(), 4); asserteq!(levelcompoundtag.geti32("zPos").unwrap(), 2); ```
```rust use anvil_region::AnvilChunkProvider; use nbt::CompoundTag;
let chunkprovider = AnvilChunkProvider::new("test/region"); let mut chunkcompoundtag = CompoundTag::new(); let mut levelcompound_tag = CompoundTag::new();
// To simplify example we add only coordinates. // Full list of required tags https://minecraft.gamepedia.com/Chunkformat. levelcompoundtag.inserti32("xPos", 31); levelcompoundtag.insert_i32("zPos", 16);
chunkcompoundtag.insertcompoundtag("Level", levelcompoundtag);
chunkprovider.savechunk(31, 16, chunkcompoundtag); ```