mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-09-24 17:11:00 +00:00
chore(java2lce): get rid of compiler warnings (most of them at least)
This commit is contained in:
@@ -9,14 +9,15 @@ pub struct LegacyBlockState {
|
|||||||
pub fn map_modern_block_state(compound: &NbtCompound) -> LegacyBlockState {
|
pub fn map_modern_block_state(compound: &NbtCompound) -> LegacyBlockState {
|
||||||
map_modern_block_state_inner(compound, None)
|
map_modern_block_state_inner(compound, None)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn map_modern_block_state_with_context(
|
pub fn map_modern_block_state_with_context(
|
||||||
compound: &NbtCompound,
|
compound: &NbtCompound,
|
||||||
unknown_blocks: Option<&mut Vec<String>>,
|
unknown_blocks: Option<&mut Vec<String>>,
|
||||||
) -> LegacyBlockState {
|
) -> LegacyBlockState {
|
||||||
map_modern_block_state_inner(compound, unknown_blocks)
|
map_modern_block_state_inner(compound, unknown_blocks)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fn map_modern_block_state_inner(
|
fn map_modern_block_state_inner(
|
||||||
compound: &NbtCompound,
|
compound: &NbtCompound,
|
||||||
mut unknown_blocks: Option<&mut Vec<String>>,
|
mut unknown_blocks: Option<&mut Vec<String>>,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use super::block_mapping::{self, LegacyBlockState};
|
use super::block_mapping::{self};
|
||||||
use super::nbt;
|
use super::nbt;
|
||||||
use super::payload;
|
use super::payload;
|
||||||
const CHUNK_BLOCKS: usize = 32768;
|
const CHUNK_BLOCKS: usize = 32768;
|
||||||
@@ -19,10 +19,10 @@ pub enum JavaChunkFormat {
|
|||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct JavaChunkFormatInfo {
|
pub struct JavaChunkFormatInfo {
|
||||||
pub format: JavaChunkFormat,
|
pub format: JavaChunkFormat,
|
||||||
pub has_level_wrapper: bool,
|
pub _has_level_wrapper: bool,
|
||||||
pub data_version: i32,
|
pub _data_version: i32,
|
||||||
pub min_section_y: Option<i32>,
|
pub _min_section_y: Option<i32>,
|
||||||
pub max_section_y: Option<i32>,
|
pub _max_section_y: Option<i32>,
|
||||||
pub has_modern_entity_tags: bool,
|
pub has_modern_entity_tags: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,10 +110,10 @@ pub fn inspect_chunk(root_tag: &nbt::NbtCompound) -> JavaChunkFormatInfo {
|
|||||||
|
|
||||||
JavaChunkFormatInfo {
|
JavaChunkFormatInfo {
|
||||||
format,
|
format,
|
||||||
has_level_wrapper,
|
_has_level_wrapper: has_level_wrapper,
|
||||||
data_version,
|
_data_version: data_version,
|
||||||
min_section_y,
|
_min_section_y: min_section_y,
|
||||||
max_section_y,
|
_max_section_y: max_section_y,
|
||||||
has_modern_entity_tags,
|
has_modern_entity_tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,8 @@ pub fn convert_chunk(
|
|||||||
build_legacy_chunk_level(root_tag, new_chunk_x, new_chunk_z, preserve_dynamic, global_section_shift);
|
build_legacy_chunk_level(root_tag, new_chunk_x, new_chunk_z, preserve_dynamic, global_section_shift);
|
||||||
payload::encode_legacy_nbt(&level)
|
payload::encode_legacy_nbt(&level)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn convert_chunk_for_save(
|
pub fn convert_chunk_for_save(
|
||||||
root_tag: &nbt::NbtCompound,
|
root_tag: &nbt::NbtCompound,
|
||||||
new_chunk_x: i32,
|
new_chunk_x: i32,
|
||||||
@@ -416,7 +417,7 @@ pub fn convert_chunk_for_save(
|
|||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
let level = build_legacy_chunk_level(root_tag, new_chunk_x, new_chunk_z, preserve_dynamic, global_section_shift);
|
let level = build_legacy_chunk_level(root_tag, new_chunk_x, new_chunk_z, preserve_dynamic, global_section_shift);
|
||||||
payload::encode_compressed_storage(&level)
|
payload::encode_compressed_storage(&level)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn build_legacy_chunk_level(
|
fn build_legacy_chunk_level(
|
||||||
root_tag: &nbt::NbtCompound,
|
root_tag: &nbt::NbtCompound,
|
||||||
@@ -430,7 +431,7 @@ fn build_legacy_chunk_level(
|
|||||||
.compound("Level")
|
.compound("Level")
|
||||||
.unwrap_or(root_tag);
|
.unwrap_or(root_tag);
|
||||||
let is_modern = format_info.uses_modern_content_schema();
|
let is_modern = format_info.uses_modern_content_schema();
|
||||||
let (mut blocks, mut data, mut sky_light, mut block_light) =
|
let (mut blocks, mut data, mut sky_light, block_light) =
|
||||||
if format_info.is_section_based() {
|
if format_info.is_section_based() {
|
||||||
flatten_anvil_sections(source_level, &format_info, global_section_shift)
|
flatten_anvil_sections(source_level, &format_info, global_section_shift)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,14 +59,15 @@ impl NbtCompound {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn compound_mut(&mut self, name: &str) -> Option<&mut NbtCompound> {
|
pub fn compound_mut(&mut self, name: &str) -> Option<&mut NbtCompound> {
|
||||||
self.get_mut(name).and_then(|v| match v {
|
self.get_mut(name).and_then(|v| match v {
|
||||||
NbtValue::Compound(c) => Some(c),
|
NbtValue::Compound(c) => Some(c),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pub fn byte(&self, name: &str) -> Option<i8> {
|
pub fn byte(&self, name: &str) -> Option<i8> {
|
||||||
self.get(name).and_then(|v| match v {
|
self.get(name).and_then(|v| match v {
|
||||||
NbtValue::Byte(b) => Some(*b),
|
NbtValue::Byte(b) => Some(*b),
|
||||||
@@ -94,7 +95,8 @@ impl NbtCompound {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn float(&self, name: &str) -> Option<f32> {
|
pub fn float(&self, name: &str) -> Option<f32> {
|
||||||
self.get(name).and_then(|v| match v {
|
self.get(name).and_then(|v| match v {
|
||||||
NbtValue::Float(f) => Some(*f),
|
NbtValue::Float(f) => Some(*f),
|
||||||
@@ -108,6 +110,7 @@ impl NbtCompound {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pub fn string(&self, name: &str) -> Option<&str> {
|
pub fn string(&self, name: &str) -> Option<&str> {
|
||||||
self.get(name).and_then(|v| match v {
|
self.get(name).and_then(|v| match v {
|
||||||
@@ -143,7 +146,8 @@ impl NbtCompound {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn list_compounds(&self, name: &str) -> Vec<&NbtCompound> {
|
pub fn list_compounds(&self, name: &str) -> Vec<&NbtCompound> {
|
||||||
self.list(name)
|
self.list(name)
|
||||||
.unwrap_or(&[])
|
.unwrap_or(&[])
|
||||||
@@ -153,7 +157,7 @@ impl NbtCompound {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tag_type_id(v: &NbtValue) -> u8 {
|
fn tag_type_id(v: &NbtValue) -> u8 {
|
||||||
@@ -405,6 +409,8 @@ pub fn write_gzip_nbt(compound: &NbtCompound) -> Vec<u8> {
|
|||||||
encoder.finish().unwrap()
|
encoder.finish().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn read_zlib_nbt(data: &[u8]) -> Result<NbtCompound, String> {
|
pub fn read_zlib_nbt(data: &[u8]) -> Result<NbtCompound, String> {
|
||||||
use flate2::read::ZlibDecoder;
|
use flate2::read::ZlibDecoder;
|
||||||
let mut decoder = ZlibDecoder::new(data);
|
let mut decoder = ZlibDecoder::new(data);
|
||||||
@@ -461,7 +467,7 @@ pub fn get_long_array_or(compound: &NbtCompound, name: &str, default_len: usize)
|
|||||||
})
|
})
|
||||||
.unwrap_or_else(|| vec![0i64; default_len])
|
.unwrap_or_else(|| vec![0i64; default_len])
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pub fn get_nibble(data: &[u8], index: usize) -> u8 {
|
pub fn get_nibble(data: &[u8], index: usize) -> u8 {
|
||||||
let byte_index = index >> 1;
|
let byte_index = index >> 1;
|
||||||
if byte_index >= data.len() {
|
if byte_index >= data.len() {
|
||||||
@@ -487,10 +493,12 @@ pub fn set_nibble(data: &mut [u8], index: usize, value: u8) {
|
|||||||
data[byte_index] = (data[byte_index] & 0x0F) | (val << 4);
|
data[byte_index] = (data[byte_index] & 0x0F) | (val << 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn clone_or_empty_list(compound: &NbtCompound, name: &str) -> Vec<NbtValue> {
|
pub fn clone_or_empty_list(compound: &NbtCompound, name: &str) -> Vec<NbtValue> {
|
||||||
compound
|
compound
|
||||||
.list(name)
|
.list(name)
|
||||||
.map(|l| l.to_vec())
|
.map(|l| l.to_vec())
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fn read_be_i64(data: &[u8], off: usize) -> i64 {
|
|||||||
data[off + 6], data[off + 7],
|
data[off + 6], data[off + 7],
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn write_be_i16(out: &mut Vec<u8>, v: i16) {
|
fn write_be_i16(out: &mut Vec<u8>, v: i16) {
|
||||||
out.extend_from_slice(&v.to_be_bytes());
|
out.extend_from_slice(&v.to_be_bytes());
|
||||||
}
|
}
|
||||||
@@ -39,14 +40,15 @@ fn write_be_i32(out: &mut Vec<u8>, v: i32) {
|
|||||||
|
|
||||||
fn write_be_i64(out: &mut Vec<u8>, v: i64) {
|
fn write_be_i64(out: &mut Vec<u8>, v: i64) {
|
||||||
out.extend_from_slice(&v.to_be_bytes());
|
out.extend_from_slice(&v.to_be_bytes());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn get_compressed_tile_index(block: usize, tile: usize) -> usize {
|
fn get_compressed_tile_index(block: usize, tile: usize) -> usize {
|
||||||
let mut index = ((block & 0x180) << 6) | ((block & 0x060) << 4) | ((block & 0x01F) << 2);
|
let mut index = ((block & 0x180) << 6) | ((block & 0x060) << 4) | ((block & 0x01F) << 2);
|
||||||
index |= ((tile & 0x30) << 7) | ((tile & 0x0C) << 5) | (tile & 0x03);
|
index |= ((tile & 0x30) << 7) | ((tile & 0x0C) << 5) | (tile & 0x03);
|
||||||
index
|
index
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn get_nibble_value(nibble_data: &[u8], xz: usize, y: usize) -> u8 {
|
fn get_nibble_value(nibble_data: &[u8], xz: usize, y: usize) -> u8 {
|
||||||
let pos = (xz << 7) | y;
|
let pos = (xz << 7) | y;
|
||||||
let slot = pos >> 1;
|
let slot = pos >> 1;
|
||||||
@@ -60,7 +62,7 @@ fn get_nibble_value(nibble_data: &[u8], xz: usize, y: usize) -> u8 {
|
|||||||
} else {
|
} else {
|
||||||
(b >> 4) & 0x0F
|
(b >> 4) & 0x0F
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn set_nibble_value(nibble_data: &mut [u8], xz: usize, y: usize, value: u8) {
|
fn set_nibble_value(nibble_data: &mut [u8], xz: usize, y: usize, value: u8) {
|
||||||
let pos = (xz << 7) | y;
|
let pos = (xz << 7) | y;
|
||||||
@@ -77,6 +79,8 @@ fn set_nibble_value(nibble_data: &mut [u8], xz: usize, y: usize, value: u8) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn ensure_length(input: &[u8], expected_len: usize) -> Vec<u8> {
|
fn ensure_length(input: &[u8], expected_len: usize) -> Vec<u8> {
|
||||||
if input.len() == expected_len {
|
if input.len() == expected_len {
|
||||||
return input.to_vec();
|
return input.to_vec();
|
||||||
@@ -115,7 +119,7 @@ fn extract_upper_block_section(full_blocks: &[u8]) -> Vec<u8> {
|
|||||||
upper[dst_start..dst_start + COMPRESSED_CHUNK_SECTION_HEIGHT].copy_from_slice(&full_blocks[src_start..src_start + COMPRESSED_CHUNK_SECTION_HEIGHT]);
|
upper[dst_start..dst_start + COMPRESSED_CHUNK_SECTION_HEIGHT].copy_from_slice(&full_blocks[src_start..src_start + COMPRESSED_CHUNK_SECTION_HEIGHT]);
|
||||||
}
|
}
|
||||||
upper
|
upper
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn extract_lower_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
fn extract_lower_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
||||||
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
|
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
|
||||||
@@ -135,7 +139,8 @@ fn extract_lower_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
|||||||
}
|
}
|
||||||
lower
|
lower
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn extract_upper_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
fn extract_upper_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
||||||
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
|
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
|
||||||
if full_nibbles.len() < FULL_CHUNK_NIBBLES {
|
if full_nibbles.len() < FULL_CHUNK_NIBBLES {
|
||||||
@@ -149,7 +154,7 @@ fn extract_upper_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
|
|||||||
.copy_from_slice(&full_nibbles[src_start..src_start + nibble_height]);
|
.copy_from_slice(&full_nibbles[src_start..src_start + nibble_height]);
|
||||||
}
|
}
|
||||||
upper
|
upper
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn combine_block_sections(lower: &[u8], upper: &[u8]) -> Vec<u8> {
|
fn combine_block_sections(lower: &[u8], upper: &[u8]) -> Vec<u8> {
|
||||||
if lower.len() == FULL_CHUNK_BLOCKS {
|
if lower.len() == FULL_CHUNK_BLOCKS {
|
||||||
@@ -205,6 +210,8 @@ pub fn encode_legacy_nbt(level: &nbt::NbtCompound) -> Vec<u8> {
|
|||||||
nbt::write_nbt(&root)
|
nbt::write_nbt(&root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn write_compressed_tile_storage(out: &mut Vec<u8>, blocks: &[u8]) {
|
fn write_compressed_tile_storage(out: &mut Vec<u8>, blocks: &[u8]) {
|
||||||
let normalized = ensure_length(blocks, BLOCKS_PER_SECTION);
|
let normalized = ensure_length(blocks, BLOCKS_PER_SECTION);
|
||||||
let mut blob = vec![0u8; 1024 + BLOCKS_PER_SECTION];
|
let mut blob = vec![0u8; 1024 + BLOCKS_PER_SECTION];
|
||||||
@@ -321,7 +328,7 @@ pub fn encode_compressed_storage(level: &nbt::NbtCompound) -> Vec<u8> {
|
|||||||
let dynamic_bytes = nbt::write_nbt(&dynamic_root);
|
let dynamic_bytes = nbt::write_nbt(&dynamic_root);
|
||||||
out.extend_from_slice(&dynamic_bytes);
|
out.extend_from_slice(&dynamic_bytes);
|
||||||
out
|
out
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn is_compressed_chunk_storage(data: &[u8]) -> bool {
|
fn is_compressed_chunk_storage(data: &[u8]) -> bool {
|
||||||
if data.len() < 2 + 4 + 4 + 8 {
|
if data.len() < 2 + 4 + 4 + 8 {
|
||||||
@@ -330,7 +337,8 @@ fn is_compressed_chunk_storage(data: &[u8]) -> bool {
|
|||||||
let version = read_be_i16(data, 0);
|
let version = read_be_i16(data, 0);
|
||||||
version == SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE || version == SAVE_FILE_VERSION_CHUNK_INHABITED_TIME
|
version == SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE || version == SAVE_FILE_VERSION_CHUNK_INHABITED_TIME
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn try_read_chunk_coordinates(
|
pub fn try_read_chunk_coordinates(
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Option<(i32, i32, bool)> {
|
) -> Option<(i32, i32, bool)> {
|
||||||
@@ -382,7 +390,7 @@ pub fn force_chunk_coordinates(data: &[u8], expected_x: i32, expected_z: i32) ->
|
|||||||
|
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fn read_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<Vec<u8>, String> {
|
fn read_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<Vec<u8>, String> {
|
||||||
let allocated_size = read_be_i32(data, *offset) as usize;
|
let allocated_size = read_be_i32(data, *offset) as usize;
|
||||||
*offset += 4;
|
*offset += 4;
|
||||||
@@ -445,7 +453,8 @@ fn read_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<Vec<u
|
|||||||
|
|
||||||
Ok(blocks)
|
Ok(blocks)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn skip_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
|
fn skip_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
|
||||||
let allocated_size = read_be_i32(data, *offset) as usize;
|
let allocated_size = read_be_i32(data, *offset) as usize;
|
||||||
*offset += 4;
|
*offset += 4;
|
||||||
@@ -455,6 +464,7 @@ fn skip_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<(), S
|
|||||||
*offset += allocated_size;
|
*offset += allocated_size;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
fn read_sparse_nibble_storage(data: &[u8], offset: &mut usize, supports_all_fifteen: bool) -> Result<Vec<u8>, String> {
|
fn read_sparse_nibble_storage(data: &[u8], offset: &mut usize, supports_all_fifteen: bool) -> Result<Vec<u8>, String> {
|
||||||
let count = read_be_i32(data, *offset) as usize;
|
let count = read_be_i32(data, *offset) as usize;
|
||||||
@@ -496,7 +506,8 @@ fn read_sparse_nibble_storage(data: &[u8], offset: &mut usize, supports_all_fift
|
|||||||
|
|
||||||
Ok(nibble_data)
|
Ok(nibble_data)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
fn skip_sparse_nibble_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
|
fn skip_sparse_nibble_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
|
||||||
let count = read_be_i32(data, *offset) as usize;
|
let count = read_be_i32(data, *offset) as usize;
|
||||||
*offset += 4;
|
*offset += 4;
|
||||||
@@ -507,7 +518,7 @@ fn skip_sparse_nibble_storage(data: &[u8], offset: &mut usize) -> Result<(), Str
|
|||||||
*offset += storage_bytes;
|
*offset += storage_bytes;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fn read_sized_bytes(data: &[u8], offset: &mut usize, length: usize) -> Vec<u8> {
|
fn read_sized_bytes(data: &[u8], offset: &mut usize, length: usize) -> Vec<u8> {
|
||||||
let end = (*offset + length).min(data.len());
|
let end = (*offset + length).min(data.len());
|
||||||
let result = data[*offset..end].to_vec();
|
let result = data[*offset..end].to_vec();
|
||||||
@@ -636,7 +647,8 @@ fn decode_compressed_chunk_to_legacy_root(data: &[u8]) -> Result<nbt::NbtCompoun
|
|||||||
root.insert("Level", nbt::NbtValue::Compound(level));
|
root.insert("Level", nbt::NbtValue::Compound(level));
|
||||||
Ok(root)
|
Ok(root)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn try_get_compressed_chunk_nbt_offset(data: &[u8]) -> Option<usize> {
|
pub fn try_get_compressed_chunk_nbt_offset(data: &[u8]) -> Option<usize> {
|
||||||
if !is_compressed_chunk_storage(data) {
|
if !is_compressed_chunk_storage(data) {
|
||||||
return None;
|
return None;
|
||||||
@@ -681,3 +693,4 @@ pub fn try_get_compressed_chunk_nbt_offset(data: &[u8]) -> Option<usize> {
|
|||||||
|
|
||||||
Some(offset)
|
Some(offset)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ impl JavaWorldReader {
|
|||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn is_anvil_world(&self) -> bool {
|
pub fn is_anvil_world(&self) -> bool {
|
||||||
let region_dir = self.get_region_dir("");
|
let region_dir = self.get_region_dir("");
|
||||||
let dir_path = Path::new(®ion_dir);
|
let dir_path = Path::new(®ion_dir);
|
||||||
@@ -89,7 +90,7 @@ impl JavaWorldReader {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fn get_or_create_reader(&mut self, region_path: &str) -> Result<&JavaRegionReader, String> {
|
fn get_or_create_reader(&mut self, region_path: &str) -> Result<&JavaRegionReader, String> {
|
||||||
if !self.region_readers.contains_key(region_path) {
|
if !self.region_readers.contains_key(region_path) {
|
||||||
let reader = JavaRegionReader::open(region_path)?;
|
let reader = JavaRegionReader::open(region_path)?;
|
||||||
@@ -97,7 +98,8 @@ impl JavaWorldReader {
|
|||||||
}
|
}
|
||||||
Ok(self.region_readers.get(region_path).unwrap())
|
Ok(self.region_readers.get(region_path).unwrap())
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn has_chunk(&mut self, region_path: &str, local_x: i32, local_z: i32) -> bool {
|
pub fn has_chunk(&mut self, region_path: &str, local_x: i32, local_z: i32) -> bool {
|
||||||
let reader = match self.get_or_create_reader(region_path) {
|
let reader = match self.get_or_create_reader(region_path) {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
@@ -106,7 +108,7 @@ impl JavaWorldReader {
|
|||||||
let index = (local_x & 31) + (local_z & 31) * 32;
|
let index = (local_x & 31) + (local_z & 31) * 32;
|
||||||
reader.offsets[index as usize] != 0
|
reader.offsets[index as usize] != 0
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
pub fn read_chunk_nbt(
|
pub fn read_chunk_nbt(
|
||||||
&mut self,
|
&mut self,
|
||||||
region_path: &str,
|
region_path: &str,
|
||||||
@@ -721,7 +723,8 @@ pub fn decompress_zlib(data: &[u8]) -> Result<Vec<u8>, String> {
|
|||||||
decoder.read_to_end(&mut buf).map_err(|e| format!("zlib decompress failed: {}", e))?;
|
decoder.read_to_end(&mut buf).map_err(|e| format!("zlib decompress failed: {}", e))?;
|
||||||
Ok(buf)
|
Ok(buf)
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
//neo: unused
|
||||||
pub fn decompress_rle_zlib(data: &[u8], decompressed_size: usize) -> Result<Vec<u8>, String> {
|
pub fn decompress_rle_zlib(data: &[u8], decompressed_size: usize) -> Result<Vec<u8>, String> {
|
||||||
let rle_data = decompress_zlib(data)?;
|
let rle_data = decompress_zlib(data)?;
|
||||||
Ok(rle_decode(&rle_data, decompressed_size))
|
Ok(rle_decode(&rle_data, decompressed_size))
|
||||||
@@ -800,3 +803,4 @@ pub fn rle_decode(data: &[u8], expected_size: usize) -> Vec<u8> {
|
|||||||
|
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user