fn correct_data_and_palette(data: &mut BitArray, palette: &mut Vec<u16>) {
        let original_palette = palette.clone(); // Palette without sorting guarantees

        palette.sort_unstable();

        for x in 0..16 {
            for y in 0..16 {
                for z in 0..16 {
                    // Replace index into palette of each block with
                    // new index into the sorted palette.
                    let block_index = block_index(x, y, z);
                    let old_index = data.get(block_index);
                    let new_index = palette
                        .binary_search(&original_palette[old_index as usize])
                        .unwrap();
                    data.set(block_index, new_index as u64);
                }
            }
        }
    }
/// Corrects a given raw palette and data array.
///
/// Since chunk data stored by external sources
/// (e.g. Vanilla) might not require a sorted palette
/// like Feather does, we need to sort the palette and
/// correct data in the array when reading from external
/// sources.
///
/// The correction is done in-place.
Corrects a given raw palette and data array.
Since chunk data stored by external sources
might not require a sorted palette
like Feather does, we need to sort the palette and
correct data in the array when reading from external
sources.

The correction is done in-place.
Corrects a given raw palette and data array . Since chunk data stored by external sources might not require a sorted palette like Feather does we need to sort the palette and correct data in the array when reading from external sources . The correction is done in - place .
fn correct_data_and_palette(data: &mut BitArray, palette: &mut Vec<u16>) {
        let original_palette = palette.clone(); // Palette without sorting guarantees
        palette.sort_unstable();
        for x in 0..16 {
            for y in 0..16 {
                for z in 0..16 {
                    // Replace index into palette of each block with
                    // new index into the sorted palette.
                    let block_index = block_index(x, y, z);
                    let old_index = data.get(block_index);
                    let new_index = palette
                        .binary_search(&original_palette[old_index as usize])
                        .unwrap();
                    data.set(block_index, new_index as u64);
                }
            }
        }
    }
fn correct_data_and_palette ( data : & mut BitArray , palette : & mut Vec < u16 > ) { let original_palette = palette . clone ( ) ; // Palette without sorting guarantees palette . sort_unstable ( ) ; for x in 0 .. 16 { for y in 0 .. 16 { for z in 0 .. 16 { // Replace index into palette of each block with // new index into the sorted palette. let block_index = block_index ( x , y , z ) ; let old_index = data . get ( block_index ) ; let new_index = palette . binary_search ( & original_palette [ old_index as usize ] ) . unwrap ( ) ; data . set ( block_index , new_index as u64 ) ; } } } }
Corrects a given raw palette and data array.
Corrects a given raw palette and data array .
data
&mut BitArray
palette
&mut Vec<u16>
data
&mut BitArray
palette
&mut Vec<u16>