Skip to content

Commit

Permalink
Revert "Fix HMCL-dev#2687 (HMCL-dev#2688)"
Browse files Browse the repository at this point in the history
This reverts commit 207b4d0.
  • Loading branch information
Glavo committed Oct 17, 2024
1 parent 9914658 commit 5ef24ff
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTFileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.jackhuang.hmcl.util.io.FileUtils;

import java.io.*;
import java.util.Arrays;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
Expand All @@ -18,22 +17,8 @@ public enum NBTFileType {
COMPRESSED("dat", "dat_old") {
@Override
public Tag read(File file) throws IOException {
try (BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(file))) {
fileInputStream.mark(3);
byte[] header = new byte[3];
if (fileInputStream.read(header) < 3) {
throw new IOException("File is too small");
}
fileInputStream.reset();

InputStream input;
if (Arrays.equals(header, new byte[]{0x1f, (byte) 0x8b, 0x08})) {
input = new GZIPInputStream(fileInputStream);
} else {
input = fileInputStream;
}

Tag tag = NBTIO.readTag(input);
try (InputStream in = new GZIPInputStream(new FileInputStream(file))) {
Tag tag = NBTIO.readTag(in);
if (!(tag instanceof CompoundTag))
throw new IOException("Unexpected tag: " + tag);
return tag;
Expand Down

0 comments on commit 5ef24ff

Please sign in to comment.