Crate mca_parser
source ·Expand description
mca-parser
mca-parser does exactly what it says on the tin. It parses Minecraft’s mca files into a format that can be used by rust programs.
The Minecraft Wiki is incredibly helpful for detailed information about the region format and the chunks within, I’d recommend using it as a reference when using this crate:
Usage Example
// Get a region from a given file
let my_region = mca_parser::from_file("r.0.0.mca")?;
// Get the chunk at (0, 0)
if let Some(my_chunk) = my_region.get_chunk(ChunkPosition::new(0, 0)) {
// Get the nbt data for that chunk
let my_nbt = my_chunk.get_nbt()?;
}
Modules
- This module contains all structs related to the nbt data in the chunks
Macros
- A simple macro that converts a 4 byte array/slice/vec/etc into a u32 using big_endian This is used rather than
u32::from_be_bytes
because it consumes the array
Structs
- Represents all data for any given chunk that can be taken from the region file
- Represnts a chunk’s payload
- Represents a Dimension with its id and its regions
- Represents a chunk’s location in the region file
- Represents the contents of a region file
- The struct used for parsing the region data
Enums
- Represents the compression type for a chunk’s payload
- Represents the id for any given dimension, using the default values that Minecraft uses: -1: Nether 0: Overworld 1: End
Functions
- Get a Vec of Regions by parsing all region files in the current folder. If the file does not end with “.mca”, then it will be ignored.
- Parse a single “.mca” file into a Region. This will return an error if the file is not a valid Region file. The coordinates of the region is taken from the name (r.0.0.mca -> (0, 0)), if the filename does not fit this format, (0, 0) will be used
- Get a list of regions from a singleplayer world directory