GithubHelp home page GithubHelp logo

szeweq / mc-repack Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 0.0 452 KB

A Minecraft mod repacking tool to optimize size and loading speed of mods.

Home Page: https://szeweq.xyz/mc-repack

License: MIT License

Rust 97.38% PowerShell 2.62%
minecraft minecraft-mod optimization optimizer repack rust rust-cli

mc-repack's People

Contributors

szeweq avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mc-repack's Issues

Suggestions - GitHub Actions

I have a suggestion which would be useful for me and perhaps for other creators:

  • Create a GitHub Action.

I am currently having to use the following combination:

- name: Install tools
  uses: baptiste0928/[email protected]
  with:
    crate: mc-repack
- name: Clean files
  run: mc-repack "/home/runner/work/[repository-name]/[repository-name]/build/libs/" --out "/home/runner/work/[repository-name]/[repository-name]/build/libs/clean/"

Note:

  1. I have to include full path.
  2. I can't use a environment variable.

If there is anything I can do to help, let me know.

Compression Improvements

Hi,
just found your project and this looks rather interesting.

Here's a couple of improvements/changes that would be amazing if they could be added:

  • Explode nested jars and recursively repack them. however, in those nested jars only ever STORE files. then add DEFLATE compression at the final level. Separate issue: #3
  • Sort files by their extension. When files of the same type are beside each other in a nested jar file, it will be able to be better compressed. (based on some rudementary testing, this combined with the previous item, can drastically improve the compression at times) Separate issue: #3
  • Ability to specify oxipng level
  • Recompress nbt files (they are just gzip compressed, so uncompress then attempt to recompress at level 9), then STORE them. Separate issue: #4
  • Don't include zip entries for the directories. fun fact: you don't need zip entries for directories!

Based on a quick little command I ran, I recorded the frequencies of different file types present in jar files.
The command used was

mkdir ./tmp
# copy a bunch of jars into this temporary directory
for i in *.jar; do
    unzd "$i"
done

find . -type f \( -iname '*.jar' -o -iname '*.zip' \) -print0 \
    | xargs -0 -n1 unzip -qqql \
    | perl -0777 -C -pe 's/.*?\/?(.*\.(.*))?/\2/g' \
    | sed '/^$/d' \
    | sort \
    | uniq -c \
    | sort -n \
    | awk '{s+=$1; print $0} END {print s}'
# note: the last line is the total count of all files. this isn't by any means perfect, but whatever.

Here are the results from that:

% of files in jar file extension
51.13% .class
31.34% .json
10.01% .png
2.5% .nbt
1.69% .ogg
0.51% .MF
0.4% .jar
0.28% .mcmeta
0.23% .xdelta (I have no clue what this file format is)
0.23% .md5
0.21% .properties
0.14% .at
0.1% .txt
0.1% .accesswidener
0.09% .xml
0.07% .md
0.06% .js

Based on this, I think it might be reasonable to consider adding optimization processes for the following files:

  • .ogg files. These can possibly be optimized using ffmpeg. (you could possibly consider decreasing the quality to increase compression. a cli arg for this would be nice.) (there seem to be a couple of crates that provide ffmpeg support, so those could be considered)
  • .nbt files. They are just gzip compressed binary data, so uncompress then recompress with level 9, then STORE them.
  • .properties files. Blank lines can be stripped from these. (it doesn't make up a large amount of the files, but it's an easy addition)
  • .accesswidener files. Blank lines can be stripped from these, as well as any lines starting with a hash (#) are comments. (it doesn't make up a large amount of the files, but it's an easy addition)

It's probably not worth it to consider additional compressors for files not in that table as they appear so infrequently it just won't make much of a difference.

Do note however, that this is not based off of the size of the files in the jar, rather just their count. may make something basic to calculate this using the size later.

NBT minifier

NBT files (from Notch's design) have its data compressed using Gzip. MC-Repack should have a special minifier for checking and recompressing this file format. (Suggestion from #2)

It should use either gzip or zopfli.

Jar-in-jar minifier

MC-Repack should have a minifier for handling JAR files stored inside another JAR file. (Suggestion from #2)

  • This implementation must not break the JAR files stored in a file system,
  • This minifier should be user-configured by CLI options,
  • Add an option to make jar-in-jar file entries be stored or deflated and jar-in-jar itself be compressed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.