Expand description
This crate lets you read the world data of a minetest world.
Only map format version 29 is supported. LevelDB backend is not supported.
§Terminology
§Node
Nodes are the single voxels that the world data consist of. They have three properties:
- A content type, which is represented by an itemstring
like
airordefault:dirt - Flags to determine lighting rendering
- Additional data that can be interpreted based on the content type (e.g. flow information for liquids)
This term might originate in the Irrlicht engine.
§MapBlock
When saved in a backend, the world data is divided into chunks that are called map blocks. A map block contains 16·16·16 nodes as well as objects and metadata.
A mapblock is addressed by a Position where every dimension
is divided by MAPBLOCK_LENGTH.
§Example usage
This code snippet that reads all nodes of a specific map block:
use minetestworld::{World, Position};
use tokio::task;
let blockpos = Position {
x: -13,
y: -8,
z: 2,
};
async {
let world = World::open("TestWorld");
let mapdata = world.get_map_data().await.unwrap();
for (pos, node) in mapdata.iter_mapblock_nodes(blockpos).await.unwrap() {
println!("{pos:?}, {node:?}");
}
};Another notable example
uses a VoxelManip to modify the world.
Re-exports§
pub use map_block::MapBlock;pub use map_block::Node;pub use map_data::MapData;pub use map_data::MapDataError;pub use positions::Position;pub use voxel_manip::VoxelManip;pub use world::World;pub use world::WorldError as Error;pub use map_block::MAPBLOCK_LENGTH;pub use map_block::MAPBLOCK_SIZE;
Modules§
- map_
block - Contains data types and constants to work with MapBlocks
- map_
data - Contains a type to read a world’s map data
- positions
- Functions and datatypes to work with world coordinates
- voxel_
manip - Contains a type to more high-level world reading and writing
- world
- Contains the
Worldalong withWorldError