/// Saves chunk data to the specified coordinates.
///
/// # Example
///
/// ```
/// use anvil_region::AnvilChunkProvider;
/// use nbt::CompoundTag;
///
/// let chunk_provider = AnvilChunkProvider::new("test/region");
/// let mut chunk_compound_tag = CompoundTag::new();
/// let mut level_compound_tag = CompoundTag::new();
///
/// // To simplify example we add only coordinates.
/// // Full list of required tags https://minecraft.gamepedia.com/Chunk_format.
/// level_compound_tag.insert_i32("xPos", 31);
/// level_compound_tag.insert_i32("zPos", 16);
///
/// chunk_compound_tag.insert_compound_tag("Level", level_compound_tag);
///
/// chunk_provider.save_chunk(31, 16, chunk_compound_tag);
/// ```
Saves chunk data to the specified coordinates.
Saves chunk data to the specified coordinates .
pub fn save_chunk(
        &self,
        chunk_x: i32,
        chunk_z: i32,
        chunk_compound_tag: CompoundTag,
    ) -> Result<(), ChunkSaveError> {
        if !self.folder_path.exists() {
            fs::create_dir(self.folder_path)?;
        }
        let region_x = chunk_x >> 5;
        let region_z = chunk_z >> 5;
        let region_chunk_x = (chunk_x & 31) as u8;
        let region_chunk_z = (chunk_z & 31) as u8;
        let region_name = format!("r.{}.{}.mca", region_x, region_z);
        let region_path = self.folder_path.join(region_name);
        // TODO: Cache region files.
        let mut region = AnvilRegion::new(region_path)?;
        region.write_chunk(region_chunk_x, region_chunk_z, chunk_compound_tag)
    }
pub fn save_chunk ( & self , chunk_x : i32 , chunk_z : i32 , chunk_compound_tag : CompoundTag , ) -> Result < ( ) , ChunkSaveError > { if ! self . folder_path . exists ( ) { fs :: create_dir ( self . folder_path ) ? ; } let region_x = chunk_x >> 5 ; let region_z = chunk_z >> 5 ; let region_chunk_x = ( chunk_x & 31 ) as u8 ; let region_chunk_z = ( chunk_z & 31 ) as u8 ; let region_name = format ! ( " " region_x region_z ) ; let region_path = self . folder_path . join ( region_name ) ; // TODO: Cache region files. let mut region = AnvilRegion :: new ( region_path ) ? ; region . write_chunk ( region_chunk_x , region_chunk_z , chunk_compound_tag ) }
Saves chunk data to the specified coordinates.
Saves chunk data to the specified coordinates .
&self
chunk_x
i32
chunk_z
i32
chunk_compound_tag
CompoundTag
example
```
use anvil_region::AnvilChunkProvider;
use nbt::CompoundTag.

let chunk_provider = AnvilChunkProvider::new("test/region");
let mut chunk_compound_tag = CompoundTag::new();
let mut level_compound_tag = CompoundTag::new().

To simplify example we add only coordinates.

chunk_compound_tag.insert_compound_tag("Level", level_compound_tag).

chunk_provider.save_chunk(31, 16, chunk_compound_tag);
```
` ` ` use anvil_region :: AnvilChunkProvider ; use nbt :: CompoundTag . let chunk_provider = AnvilChunkProvider :: new ( " test / region " ) ; let mut chunk_compound_tag = CompoundTag :: new () ; let mut level_compound_tag = CompoundTag :: new () . To simplify example we add only coordinates . chunk_compound_tag . insert_compound_tag ( " Level " level_compound_tag ) . chunk_provider . save_chunk ( 31 16 chunk_compound_tag ) ; ` ` `