MCPcopy Index your code
hub / github.com/ComunidadAylas/PackSquash

github.com/ComunidadAylas/PackSquash @v0.4.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.1 ↗ · + Follow
546 symbols 1,073 edges 65 files 225 documented · 41%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

PackSquash

CI workflow status Latest version Total downloads Discord server online count

PackSquash is a Minecraft: Java Edition resource and data pack optimizer which aims to achieve the best possible compression, performance, and protection, improving pack distribution, storage, and in-game load times.

Anecdotal evidence shows that, with the default options, version v0.2.1 was capable of reducing the size of the Witchcraft & Wizardary resource pack ZIP file by Floo Network (version 1.6.2) from 118 MiB to 57 MiB, a 51.69% size reduction, and it got better over time.

🔎 Overview

PackSquash walks through the pack files that it recognizes in a directory, applies per-file configurable lossy and lossless compression techniques, and builds a ZIP file that can be directly used by the game. Currently, PackSquash can apply the following specific techniques:

  • For PNG images: color quantization to generate a color palette, lossless bit depth, compression and color type reduction, metadata removal, and downsizing of single-color textures. The quantization, although it is pretty subtle or even unneeded for common texture sizes, can be disabled if lossless quality is desired. Downsizing can also be turned off. Some of these optimizations are done by the well-known imagequant (used in pngquant) and oxipng libraries.
  • For Ogg (.ogg and .oga), MP3, M4A, FLAC, and WAV files: channel mixing, downsampling, transcoding with a state-of-the-art Vorbis encoder, pitch shifting, tag removal, silence truncation, and two-pass optimization and validation with OptiVorbis. The default settings are meant to be good enough for in-game music, such that most listeners will think that the quality is good and not distracting. Because channel mixing may change how the Minecraft sound engine computes positional effects (see MC-146721), PackSquash won't do it by default.
  • For JSON files (.json, .jsonc, .mcmeta and .mcmetac; if OptiFine mod support is enabled, also .jem, .jemc, .jpm and .jpmc): minification, by removing unneeded whitespace. As a side bonus, because minification requires parsing first, PackSquash also acts as a strict JSON file validator. Comments are the only syntax extension accepted, and they are discarded by default, although they can be rejected too in files whose extension does not end with a "c" letter. The validation done doesn't catch all the possible errors that might confuse Minecraft.
  • For shader files (.vsh, .fsh and .glsl): minification, by removing unneeded whitespace, and resolution and expansion of preprocessor directives. As with JSON files, PackSquash will perform basic validation on them. Please note that due to limitations in the current design of PackSquash some shaders may require tweaking. These limitations will be addressed in the future.
  • For structure files (.nbt): recompression with Zopfli, Gzip member concatenation, and metadata removal.
  • For legacy language files (.lang; used in Minecraft 1.12.2 and lower): minification, removing blank lines and comments. Duplicate keys and non-blank lines that are not comments and do not contain a key-value separator are treated as errors, which helps catch mistakes and keep your files tidy.
  • For OptiFine properties files (Java .properties; only if OptiFine mod support is enabled): minification, by removing unneeded whitespace. As with JSON files, performing minification requires parsing the file, so PackSquash will show basic validation errors.
  • For BlockBench model files (.bbmodel; only if Minecraft Transit Railway 3 support is enabled): minification, by removing unneeded whitespace and keys. The minification might also improve privacy, as some keys containing environment-specific metadata are removed.

In addition to these techniques, the files that are not already compressed by design (namely, Ogg and PNG files) are losslessly compressed using the Zopfli algorithm, which is a state-of-the-art DEFLATE encoder made by Google. It is tuned for very high space savings at the cost of performance whilst being compatible with every DEFLATE decoder. For even higher savings, it is possible to compress already compressed files and increase the number of compression iterations, although this slows down the process significantly. Conversely, if lower savings are acceptable in exchange for faster execution, it is possible to reduce the number of compression iterations or skip it altogether.

PackSquash is also capable of doing the following things, although they are disabled by default because they require informed decisions to be made by the user:

  • Reusing the ZIP files it previously generated to skip compressing files that did not change between executions, vastly speeding it up for incremental workflows, where only a few files change each time.
  • Deduplicating identical files within the generated ZIP file: the contents of files repeated several times over will be stored only once.
  • Protecting the generated ZIP files, making them harder to read by most ZIP manipulation programs, and some of the files stored inside such ZIP files.

🔗 Download and usage

PackSquash is a command-line application distributed for a bunch of operating systems and environments. Check out the getting started guide for details on how to begin your journey with PackSquash.

Alternatively, you might be interested in third-party tools that integrate with PackSquash, such as:

  • Nexo, a Minecraft server plugin for creating custom items, blocks, armor, and more.

✉️ Contact and support

As the license says, this software is provided without any warranty, with the hope that you find it useful. But that doesn't mean I don't welcome constructive feedback, suggestions, congratulations, or assisting you on your use of PackSquash (if I can and want to). If you wish to drop me a line for whatever reason related to PackSquash, you can contact me on Discord: alextmjugador.

You can also join the Discord server of our community, Comunidad Aylas, which has dedicated spaces to welcome English-language PackSquash chat and support, among other topics. Don't forget to introduce yourself!

🎁 Sponsoring

You can use all of PackSquash for free for whatever you want and will always be able to. One of the things I enjoy the most about making free software is the feeling that I'm doing something good and useful for others. With that said, PackSquash is arguably innovative, and some things were only possible to implement thanks to original knowledge of Minecraft internals acquired via static analysis of its deobfuscated code, which is an activity that is commonly referred to as reverse engineering. This is time-consuming, and engineers in companies get paid for doing these kinds of things. If you want to say "thank you" in a way that words can't describe or motivate me to stay committed to the project and advance in the roadmap, sending me some money would be a great way to do so!

Buy me a coffee at ko-fi.com

Donate via PayPal.me

In principle, I will use any funds I receive for personal spending. However, I may decide to introduce sponsor tiers and perks (retroactively, benefiting those who sponsored the project before they got introduced too), add more payment methods, share the funds with other high-profile contributors, or use them for donations and campaigns. I will be transparent about any major decisions I make about this, communicating them in public announcements.

✨ Contributors

Thanks goes to these wonderful people and projects (emoji key):

 Alejandro González Alejandro González 💻 🖋 📖 💡 🚧 📆 🧑‍🏫 💬 🔬 🌍 👀 ⚠️ 📣 📦 Aiamded Aiamded 🤔 🐛 🔣 📓 💵 AmberFrost AmberFrost 🤔 🎨 Ben Wickham (Eraze) Ben Wickham (Eraze) 💵 🤔 CallumBugajski CallumBugajski 🐛 Chen Chen 🐛 💻 David Lüdtke David Lüdtke 🐛 🤔 📓 💬
Felixx61 Felixx61 📓 🔣 🤔 Jay Hopkins Jay Hopkins

Extension points exported contracts — how you extend this code

PackFile (Interface)
A Minecraft pack file in some format, that may be processed in order to improve its internal coding efficiency and/or it [9 …
packages/packsquash/src/pack_file.rs
TerminalTitleSetterTrait (Interface)
Defines the contract that any struct capable of setting the title of the process controlling terminal must follow. [2 …
packages/packsquash_cli/src/bin/packsquash/terminal_title_setter.rs
PackFileConstructor (Interface)
Factory trait for a [`PackFile`] that allows it to be instantiated in a standard way. It is separated from that trait be [9 …
packages/packsquash/src/pack_file.rs
TranspilableInner (Interface)
Internal trait used to encapsulate GLSL symbol-specific transpilation logic. [3 implementers]
packages/packsquash/src/pack_file/shader_file/parser.rs
VirtualFileSystem (Interface)
Defines the contract that any virtual file system must implement. [2 implementers]
packages/packsquash/src/vfs.rs
Transpilable (Interface)
Represents a GLSL grammar symbol that can be transpiled back to GLSL. [1 implementers]
packages/packsquash/src/pack_file/shader_file/parser.rs

Core symbols most depended-on inside this repo

compile_hardcoded_pack_file_glob_pattern
called by 43
packages/packsquash/src/pack_file/asset_type.rs
get
called by 39
packages/packsquash/benches/pack_dataset.rs
seek
called by 19
packages/packsquash/src/buffered_async_spooled_temp_file.rs
read
called by 19
packages/packsquash/src/pack_file/png_file/image_processor.rs
process
called by 16
packages/packsquash/src/pack_file/png_file.rs
is_empty
called by 15
packages/packsquash/src/pack_file/asset_type.rs
as_ref
called by 11
packages/packsquash/src/pack_file/audio_file.rs
random_u32
called by 9
packages/packsquash/src/squash_zip/obfuscation_engine.rs

Shape

Method 213
Function 200
Class 82
Enum 44
Interface 7

Languages

Rust100%
Python1%

Modules by API surface

packages/packsquash/src/config/mod.rs34 symbols
packages/packsquash/src/squash_zip/zip_file_record.rs22 symbols
packages/packsquash/src/squash_zip.rs17 symbols
packages/packsquash/src/pack_file/png_file/image_processor.rs17 symbols
packages/packsquash/src/lib.rs16 symbols
packages/packsquash/src/squash_zip/zip_file_record/tests.rs15 symbols
packages/packsquash/src/pack_file/shader_file/parser.rs15 symbols
packages/packsquash/src/pack_file/audio_file.rs15 symbols
packages/packsquash/src/buffered_async_spooled_temp_file.rs15 symbols
packages/packsquash/src/squash_zip/obfuscation_engine.rs14 symbols
packages/packsquash/src/pack_file/json_file/tests.rs14 symbols
packages/packsquash/src/pack_file/audio_file/signal_processor.rs14 symbols

For agents

$ claude mcp add PackSquash \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact