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 Jul 6, 2024
1 parent b2dca0b commit bb4fc7b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,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 @@ -510,6 +511,10 @@ public String getDescription() {
return description;
}

public boolean isPbrPack() {
return isPbrPack;
}

public String getFormatVersionString() {
return formatVersion <= 0
? ""
Expand Down Expand Up @@ -559,6 +564,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 bb4fc7b

Please sign in to comment.