Skip to content

Commit

Permalink
Detect PBR resource packs in the chooser.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Oct 3, 2022
1 parent 02e9828 commit f729150
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -494,6 +491,7 @@ private static void loadMissingPackPng(File minecraftJar) {

private Image icon = MISSING_PACK_PNG;
private String description = "loading …";
private boolean isPbrPack = false;
private int formatVersion = 0;

public File getFile() {
Expand All @@ -516,6 +514,10 @@ public String getDescription() {
return description;
}

public boolean isPbrPack() {
return isPbrPack;
}

public String getFormatVersionString() {
return formatVersion <= 0
? ""
Expand Down Expand Up @@ -565,6 +567,16 @@ private void parseResourcePack(File resourcePackFile) {
loadIcon(inputStream);
}
}

try {
isPbrPack = Files.walk(root.resolve("assets/minecraft/textures/block"))
.anyMatch(path -> {
String filename = path.getFileName().toString();
return filename.endsWith("_n.png") || filename.endsWith("_s.png");
});
} catch (IOException e) {
isPbrPack = false;
}
} catch (UnsupportedOperationException uoex) {
// default file systems do not support closing
} catch (IOException ioex) {
Expand Down

0 comments on commit f729150

Please sign in to comment.