chore(java2lce): get rid of compiler warnings (most of them at least)

This commit is contained in:
neoapps-dev
2026-09-17 21:50:51 +03:00
parent e961d7d9bb
commit 62792f6260
5 changed files with 67 additions and 40 deletions
@@ -9,14 +9,15 @@ pub struct LegacyBlockState {
pub fn map_modern_block_state(compound: &NbtCompound) -> LegacyBlockState {
map_modern_block_state_inner(compound, None)
}
/*
//neo: unused
pub fn map_modern_block_state_with_context(
compound: &NbtCompound,
unknown_blocks: Option<&mut Vec<String>>,
) -> LegacyBlockState {
map_modern_block_state_inner(compound, unknown_blocks)
}
*/
fn map_modern_block_state_inner(
compound: &NbtCompound,
mut unknown_blocks: Option<&mut Vec<String>>,
+13 -12
View File
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use super::block_mapping::{self, LegacyBlockState};
use super::block_mapping::{self};
use super::nbt;
use super::payload;
const CHUNK_BLOCKS: usize = 32768;
@@ -19,10 +19,10 @@ pub enum JavaChunkFormat {
#[derive(Debug, Clone, Copy)]
pub struct JavaChunkFormatInfo {
pub format: JavaChunkFormat,
pub has_level_wrapper: bool,
pub data_version: i32,
pub min_section_y: Option<i32>,
pub max_section_y: Option<i32>,
pub _has_level_wrapper: bool,
pub _data_version: i32,
pub _min_section_y: Option<i32>,
pub _max_section_y: Option<i32>,
pub has_modern_entity_tags: bool,
}
@@ -110,10 +110,10 @@ pub fn inspect_chunk(root_tag: &nbt::NbtCompound) -> JavaChunkFormatInfo {
JavaChunkFormatInfo {
format,
has_level_wrapper,
data_version,
min_section_y,
max_section_y,
_has_level_wrapper: has_level_wrapper,
_data_version: data_version,
_min_section_y: min_section_y,
_max_section_y: max_section_y,
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);
payload::encode_legacy_nbt(&level)
}
/*
//neo: unused
pub fn convert_chunk_for_save(
root_tag: &nbt::NbtCompound,
new_chunk_x: i32,
@@ -416,7 +417,7 @@ pub fn convert_chunk_for_save(
) -> Vec<u8> {
let level = build_legacy_chunk_level(root_tag, new_chunk_x, new_chunk_z, preserve_dynamic, global_section_shift);
payload::encode_compressed_storage(&level)
}
}*/
fn build_legacy_chunk_level(
root_tag: &nbt::NbtCompound,
@@ -430,7 +431,7 @@ fn build_legacy_chunk_level(
.compound("Level")
.unwrap_or(root_tag);
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() {
flatten_anvil_sections(source_level, &format_info, global_section_shift)
} else {
+15 -7
View File
@@ -59,14 +59,15 @@ impl NbtCompound {
_ => None,
})
}
/*
//neo: unused
pub fn compound_mut(&mut self, name: &str) -> Option<&mut NbtCompound> {
self.get_mut(name).and_then(|v| match v {
NbtValue::Compound(c) => Some(c),
_ => None,
})
}
*/
pub fn byte(&self, name: &str) -> Option<i8> {
self.get(name).and_then(|v| match v {
NbtValue::Byte(b) => Some(*b),
@@ -94,7 +95,8 @@ impl NbtCompound {
_ => None,
})
}
/*
//neo: unused
pub fn float(&self, name: &str) -> Option<f32> {
self.get(name).and_then(|v| match v {
NbtValue::Float(f) => Some(*f),
@@ -108,6 +110,7 @@ impl NbtCompound {
_ => None,
})
}
*/
pub fn string(&self, name: &str) -> Option<&str> {
self.get(name).and_then(|v| match v {
@@ -143,7 +146,8 @@ impl NbtCompound {
_ => None,
})
}
/*
//neo: unused
pub fn list_compounds(&self, name: &str) -> Vec<&NbtCompound> {
self.list(name)
.unwrap_or(&[])
@@ -153,7 +157,7 @@ impl NbtCompound {
_ => None,
})
.collect()
}
}*/
}
fn tag_type_id(v: &NbtValue) -> u8 {
@@ -405,6 +409,8 @@ pub fn write_gzip_nbt(compound: &NbtCompound) -> Vec<u8> {
encoder.finish().unwrap()
}
/*
//neo: unused
pub fn read_zlib_nbt(data: &[u8]) -> Result<NbtCompound, String> {
use flate2::read::ZlibDecoder;
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])
}
*/
pub fn get_nibble(data: &[u8], index: usize) -> u8 {
let byte_index = index >> 1;
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);
}
}
/*
//neo: unused
pub fn clone_or_empty_list(compound: &NbtCompound, name: &str) -> Vec<NbtValue> {
compound
.list(name)
.map(|l| l.to_vec())
.unwrap_or_default()
}
*/
+27 -14
View File
@@ -28,7 +28,8 @@ fn read_be_i64(data: &[u8], off: usize) -> i64 {
data[off + 6], data[off + 7],
])
}
/*
//neo: unused
fn write_be_i16(out: &mut Vec<u8>, v: i16) {
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) {
out.extend_from_slice(&v.to_be_bytes());
}
}*/
fn get_compressed_tile_index(block: usize, tile: usize) -> usize {
let mut index = ((block & 0x180) << 6) | ((block & 0x060) << 4) | ((block & 0x01F) << 2);
index |= ((tile & 0x30) << 7) | ((tile & 0x0C) << 5) | (tile & 0x03);
index
}
/*
//neo: unused
fn get_nibble_value(nibble_data: &[u8], xz: usize, y: usize) -> u8 {
let pos = (xz << 7) | y;
let slot = pos >> 1;
@@ -60,7 +62,7 @@ fn get_nibble_value(nibble_data: &[u8], xz: usize, y: usize) -> u8 {
} else {
(b >> 4) & 0x0F
}
}
}*/
fn set_nibble_value(nibble_data: &mut [u8], xz: usize, y: usize, value: u8) {
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> {
if input.len() == expected_len {
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
}
}*/
fn extract_lower_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
@@ -135,7 +139,8 @@ fn extract_lower_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
}
lower
}
/*
//neo: unused
fn extract_upper_nibble_section(full_nibbles: &[u8]) -> Vec<u8> {
let nibble_height = COMPRESSED_CHUNK_SECTION_HEIGHT / 2;
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]);
}
upper
}
}*/
fn combine_block_sections(lower: &[u8], upper: &[u8]) -> Vec<u8> {
if lower.len() == FULL_CHUNK_BLOCKS {
@@ -205,6 +210,8 @@ pub fn encode_legacy_nbt(level: &nbt::NbtCompound) -> Vec<u8> {
nbt::write_nbt(&root)
}
/*
//neo: unused
fn write_compressed_tile_storage(out: &mut Vec<u8>, blocks: &[u8]) {
let normalized = ensure_length(blocks, 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);
out.extend_from_slice(&dynamic_bytes);
out
}
}*/
fn is_compressed_chunk_storage(data: &[u8]) -> bool {
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);
version == SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE || version == SAVE_FILE_VERSION_CHUNK_INHABITED_TIME
}
/*
//neo: unused
pub fn try_read_chunk_coordinates(
data: &[u8],
) -> Option<(i32, i32, bool)> {
@@ -382,7 +390,7 @@ pub fn force_chunk_coordinates(data: &[u8], expected_x: i32, expected_z: i32) ->
Vec::new()
}
*/
fn read_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<Vec<u8>, String> {
let allocated_size = read_be_i32(data, *offset) as usize;
*offset += 4;
@@ -445,7 +453,8 @@ fn read_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<Vec<u
Ok(blocks)
}
/*
//neo: unused
fn skip_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
let allocated_size = read_be_i32(data, *offset) as usize;
*offset += 4;
@@ -455,6 +464,7 @@ fn skip_compressed_tile_storage(data: &[u8], offset: &mut usize) -> Result<(), S
*offset += allocated_size;
Ok(())
}
*/
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;
@@ -496,7 +506,8 @@ fn read_sparse_nibble_storage(data: &[u8], offset: &mut usize, supports_all_fift
Ok(nibble_data)
}
/*
//neo: unused
fn skip_sparse_nibble_storage(data: &[u8], offset: &mut usize) -> Result<(), String> {
let count = read_be_i32(data, *offset) as usize;
*offset += 4;
@@ -507,7 +518,7 @@ fn skip_sparse_nibble_storage(data: &[u8], offset: &mut usize) -> Result<(), Str
*offset += storage_bytes;
Ok(())
}
*/
fn read_sized_bytes(data: &[u8], offset: &mut usize, length: usize) -> Vec<u8> {
let end = (*offset + length).min(data.len());
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));
Ok(root)
}
/*
//neo: unused
pub fn try_get_compressed_chunk_nbt_offset(data: &[u8]) -> Option<usize> {
if !is_compressed_chunk_storage(data) {
return None;
@@ -681,3 +693,4 @@ pub fn try_get_compressed_chunk_nbt_offset(data: &[u8]) -> Option<usize> {
Some(offset)
}
*/
+9 -5
View File
@@ -72,7 +72,8 @@ impl JavaWorldReader {
result
}
/*
//neo: unused
pub fn is_anvil_world(&self) -> bool {
let region_dir = self.get_region_dir("");
let dir_path = Path::new(&region_dir);
@@ -89,7 +90,7 @@ impl JavaWorldReader {
}
false
}
*/
fn get_or_create_reader(&mut self, region_path: &str) -> Result<&JavaRegionReader, String> {
if !self.region_readers.contains_key(region_path) {
let reader = JavaRegionReader::open(region_path)?;
@@ -97,7 +98,8 @@ impl JavaWorldReader {
}
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 {
let reader = match self.get_or_create_reader(region_path) {
Ok(r) => r,
@@ -106,7 +108,7 @@ impl JavaWorldReader {
let index = (local_x & 31) + (local_z & 31) * 32;
reader.offsets[index as usize] != 0
}
*/
pub fn read_chunk_nbt(
&mut self,
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))?;
Ok(buf)
}
/*
//neo: unused
pub fn decompress_rle_zlib(data: &[u8], decompressed_size: usize) -> Result<Vec<u8>, String> {
let rle_data = decompress_zlib(data)?;
Ok(rle_decode(&rle_data, decompressed_size))
@@ -800,3 +803,4 @@ pub fn rle_decode(data: &[u8], expected_size: usize) -> Vec<u8> {
output
}
*/