Skip to content

Commit 4fc7ea8

Browse files
committed
Update CLI, GUI, Java API and docs to match version 0.3.0-beta.3
1 parent 7143f73 commit 4fc7ea8

15 files changed

Lines changed: 252 additions & 316 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Usage: packobf_cli [OPTIONS] --input-file <FILE> --output-file <FILE>
1515
Options:
1616
-i, --input-file <FILE>
1717
-o, --output-file <FILE>
18-
-p, --preset <PRESET> [possible values: fastest, fast, normal, best, ultra]
18+
-p, --preset <PRESET> [possible values: fast, normal, best]
1919
-l, --log-level <LOG_LEVEL> [default: info] [possible values: info, warning, error, none]
2020
--cache-file <CACHE_FILE>
21-
-c, --compression <COMPRESSION> [default: normal] [possible values: fastest, fast, normal, best, ultra]
21+
-c, --compression <COMPRESSION> [default: normal] [possible values: fast, normal]
2222
--shader-compression <SHADER_COMPRESSION> [default: minify] [possible values: none, minify, minify-and-obfuscate]
2323
--rename-files
2424
--block-unzipping
@@ -30,7 +30,7 @@ Options:
3030
```
3131

3232
> [!TIP]
33-
> Using `--preset` is a good choice when trying PackOBF for the first time, possible values are: `fastest`, `fast`, `normal`, `best`, `ultra`.
33+
> Using `--preset` is a good choice when trying PackOBF for the first time, possible values are: `fast`, `normal`, and `best`.
3434
3535
~~Alternatively, you can use PackOBF in your browser at https://packobf.misieur.me/ however, it will be way slower than the native app
3636
because of internet browser restrictions.~~ PackOBF on internet browsers is deprecated.
@@ -42,22 +42,22 @@ because of internet browser restrictions.~~ PackOBF on internet browsers is depr
4242

4343
### JSON Files
4444
PackOBF will parse JSON files into memory and will know for JSON files in `items`, `models`, `blockstates`, `fonts`, `sound_definitions`, and `atlas` folders
45-
which fields exist, which one are required, their value type (string, integer, etc.) and their default value.
45+
which fields exist, which ones are required, their type (string, integer, etc.) and their default value.
4646
With all of this data, PackOBF is able to remove fields that are unknown by Minecraft, values that are
47-
already the default one, spaces and new lines.
47+
already the default one, spaces and line breaks.
4848
> [!NOTE]
4949
> For any other JSON file, PackOBF will only simplify them, remove spaces, newlines, `.0` for numbers, etc.
5050
5151
### PNG Files
52-
PackOBF uses [oxipng](https://github.com/oxipng/oxipng) to minimize losslessly PNG files.
52+
PackOBF uses [an oxipng fork](https://github.com/PackOBF/oxipng) to losslessly minimize PNG files.
5353
Moreover, if you enable the *Corrupt PNG Files* option (`--corrupt-png-files`), your PNG images will be
5454
corrupted and unreadable for a lof of image software but Minecraft and will remove some bytes from your PNG images.
5555

5656
### Resource pack file
57-
PackOBF has its own way of writing ZIP files, which will not work with some popular ZIP file extractors,
57+
PackOBF has its own way of writing ZIP files, which will not work with some popular ZIP file extractors
5858
but does work with Minecraft. This way of writing ZIP files is not conventional, but it allows saving file size
5959
when duplicated files are in the resource pack and does not write useless data like folders and other fields on the ZIP file.
60-
PackOBF by itself will break some file software however the `jar -xf output.zip` command from Java will still be able to unzip it.
60+
PackOBF by itself will break some file software, however, the `jar -xf output.zip` command from Java will still be able to unzip it.
6161
By enabling the *Block resource pack from unzipping* option (`--block-unzipping`), it will totally block Java and a lot of software
6262
(including JD-GUI, Minecraft mods) from unzipping your resource pack while Minecraft can still load it.
6363

@@ -66,7 +66,7 @@ PackOBF is able to rename resource pack overlays, models, textures and sounds th
6666
(example: `assets/_/textures/i/a.png` instead of `assets/minecraft/textures/item/my_cool_item.png`) while keeping everything working.
6767

6868
### Core Shaders (Experimental)
69-
PackOBF is able to parse core shaders, minify them, rename variables and functions to short names, it can be enabled using the
69+
PackOBF is able to parse core shaders, minify them, rename variables and functions to short names. It can be enabled using the
7070
`--shader-compression [none, minify, minify-and-obfuscate]` option, `minify-and-obfuscate` will rename variables and functions
7171
which might break your shaders, while `minify` does not.
7272

‎docs/usage/OPTIONS.md‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616

1717
Used for any file in the resource pack and PNG images before being compressed in the resource pack.
1818

19-
| Compression level | Description |
20-
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
21-
| Fastest | Uses libdeflate level 6 |
22-
| Fast | Uses libdeflate level 12 |
23-
| Normal | Pre-processes data with libdeflate level 9 and based on the results chooses zopfli options that would give the best time/compression ratio. |
24-
| Best | Same as Normal but with higher zopfli compression. |
25-
| Ultra | Zopfli with 40 iteration_count, 40 iterations_without_improvement and 25 maximum_block_splits |
19+
| Compression level | Description |
20+
|-------------------|--------------------------------------------------|
21+
| Fast | Uses libdeflate level 6 and fast oxipng options |
22+
| Normal | Uses libdeflate level 12 and slow oxipng options |
2623

2724
> [!NOTE]
2825
> You may not want to use the Ultra compression level if it's not for testing/benchmarking

‎java/rust/src/lib.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ pub extern "system" fn Java_dev_misieur_packobf_Native_optimizeZip<'caller>(
128128
index: i,
129129
total: t,
130130
} => (3, i as i32, t as i32, Some(s)),
131-
Progress::Building {
132-
current: s,
133-
index: i,
134-
total: t,
135-
} => (4, i as i32, t as i32, Some(s)),
131+
Progress::Finishing => (4, 0, 0, None),
136132
Progress::Done => (5, 0, 0, None),
137133
};
138134

‎java/src/main/java/dev/misieur/packobf/Native.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private Native() {
1414

1515
static class Options {
1616

17-
public Options(int compression, int shaderCompression, boolean renameFiles, boolean blockUnzipping, boolean corruptPngFiles, int numThreads, int targetVersion) {
17+
Options(int compression, int shaderCompression, boolean renameFiles, boolean blockUnzipping, boolean corruptPngFiles, int numThreads, int targetVersion) {
1818
this.compression = compression;
1919
this.shaderCompression = shaderCompression;
2020
this.renameFiles = renameFiles;
@@ -24,13 +24,13 @@ public Options(int compression, int shaderCompression, boolean renameFiles, bool
2424
this.targetVersion = targetVersion;
2525
}
2626

27-
public int compression;
28-
public int shaderCompression;
29-
public boolean renameFiles;
30-
public boolean blockUnzipping;
31-
public boolean corruptPngFiles;
32-
public int numThreads;
33-
public int targetVersion;
27+
int compression;
28+
int shaderCompression;
29+
boolean renameFiles;
30+
boolean blockUnzipping;
31+
boolean corruptPngFiles;
32+
int numThreads;
33+
int targetVersion;
3434
}
3535

3636
interface LogCallback {

‎java/src/main/java/dev/misieur/packobf/PackOBF.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static byte[] optimizeZip(
7171
case 1 -> progressCallback.onProgress(new ReadingZipProgress(current, total));
7272
case 2 -> progressCallback.onProgress(new ParsingProgress(currentString));
7373
case 3 ->
74-
progressCallback.onProgress(new BuildingProgress(total, new BuildingProgress.Current(currentString, current)));
74+
progressCallback.onProgress(new FinishingProgress());
7575
case 4 -> progressCallback.onProgress(new DoneProgress());
7676
default -> {
7777
}

‎java/src/main/java/dev/misieur/packobf/options/Compression.java‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package dev.misieur.packobf.options;
22

33
public enum Compression {
4-
FASTEST(0),
5-
FAST(1),
6-
NORMAL(2),
7-
BEST(3),
8-
ULTRA(4);
4+
FAST(0),
5+
NORMAL(1);
96

107
private final int value;
118

‎java/src/main/java/dev/misieur/packobf/options/Options.java‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ public record Options(@NotNull Compression compression,
1212
@NotNull Optional<Integer> numThreads,
1313
@NotNull Optional<MinecraftVersion> targetVersion
1414
) {
15-
public static Options fastest() {
16-
return new Options(
17-
Compression.FASTEST,
18-
ShaderCompression.NONE,
19-
false,
20-
false,
21-
false,
22-
Optional.empty(),
23-
Optional.empty()
24-
);
25-
}
2615

2716
public static Options fast() {
2817
return new Options(
@@ -51,7 +40,7 @@ public static Options normal() {
5140

5241
public static Options best() {
5342
return new Options(
54-
Compression.BEST,
43+
Compression.NORMAL,
5544
ShaderCompression.NONE,
5645
true,
5746
true,
@@ -60,17 +49,4 @@ public static Options best() {
6049
Optional.empty()
6150
);
6251
}
63-
64-
65-
public static Options ultra() {
66-
return new Options(
67-
Compression.ULTRA,
68-
ShaderCompression.MINIFY_AND_OBFUSCATE,
69-
true,
70-
true,
71-
true,
72-
Optional.empty(),
73-
Optional.empty()
74-
);
75-
}
7652
}

‎java/src/main/java/dev/misieur/packobf/progress/BuildingProgress.java‎

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package dev.misieur.packobf.progress;
2+
3+
/**
4+
* No fields
5+
*/
6+
public final class FinishingProgress extends Progress {
7+
public FinishingProgress() {
8+
}
9+
10+
@Override
11+
public State state() {
12+
return State.FINISHING;
13+
}
14+
15+
public record Current(String name, int index) {
16+
}
17+
}

‎java/src/main/java/dev/misieur/packobf/progress/Progress.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dev.misieur.packobf.progress;
22

3-
public abstract sealed class Progress permits IdleProgress, ReadingZipProgress, ParsingProgress, OptimizingProgress, BuildingProgress, DoneProgress {
3+
public abstract sealed class Progress permits IdleProgress, ReadingZipProgress, ParsingProgress, OptimizingProgress, FinishingProgress, DoneProgress {
44
private State state;
55

66
public abstract State state();
@@ -10,7 +10,7 @@ public enum State {
1010
READING_ZIP(1),
1111
PARSING(2),
1212
OPTIMIZING(3),
13-
BUILDING(4),
13+
FINISHING(4),
1414
DONE(5);
1515

1616
private final int value;

0 commit comments

Comments
 (0)