From cbe9563f5c5157ec4bd51fc451eb263b17794e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 26 Oct 2024 15:59:57 +0200 Subject: [PATCH] fix: support Java 22 and newer clients for packs that disregard ZIP spec These changes were tested to work well up to Java 24 and should not impact older Java versions. Fixes #294. --- CHANGELOG.md | 3 +++ packages/packsquash/src/squash_zip/obfuscation_engine.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 296c2f058..a8d86cf93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). #### Fixed +- Packs generated with the `zip_spec_conformance_level` option set to + `disregard` now reliably work on Minecraft clients running Java 22 or newer. + (Thanks _@mrkinau_ and _@mihannnik_ for reporting the issue!) - Shaders that depend on `#moj_import`ed or parent-defined preprocessor variables to be syntactically correct or expand to the intended source code will no longer cause PackSquash to fail or change their semantics. diff --git a/packages/packsquash/src/squash_zip/obfuscation_engine.rs b/packages/packsquash/src/squash_zip/obfuscation_engine.rs index 601823e03..16650d102 100644 --- a/packages/packsquash/src/squash_zip/obfuscation_engine.rs +++ b/packages/packsquash/src/squash_zip/obfuscation_engine.rs @@ -206,12 +206,12 @@ impl ObfuscationEngine { 4096 + central_directory_header.compressed_size % 4096; } central_directory_header.local_header_disk_number = - (random_u32(seed) % 32768) as u16 + 32768; + (random_u32(seed) % 32768) as u16 + 32767; } else { if obfuscate_uncompressed_size { central_directory_header.uncompressed_size = 0xFFFFFF7F; } - central_directory_header.local_header_disk_number = u16::MAX; + central_directory_header.local_header_disk_number = u16::MAX - 1; } if let SizeIncreasingObfuscation::Enabled {