Skip to content

Commit 5bc9fab

Browse files
committed
fix crash on start up due to built in mod packs unable to load pack.png and pack.txt
1 parent 8dfca0f commit 5bc9fab

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

libraries/resource-loader/resource-loader-client-mca1.2.2-1624-mc12w30e/src/main/java/net/ornithemc/osl/resource/loader/impl/BuiltInModTexturePack.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.fabricmc.loader.api.metadata.ModMetadata;
1212

1313
import net.minecraft.client.resource.pack.AbstractTexturePack;
14+
import net.minecraft.client.resource.pack.TexturePack;
1415

1516
import net.ornithemc.osl.resource.loader.api.ModTexturePack;
1617

@@ -33,6 +34,10 @@ public InputStream getResource(String location) {
3334
Path path = getPath(location);
3435

3536
if (path == null || !Files.exists(path)) {
37+
if ("/pack.png".equals(location) || "/pack.txt".equals(location)) {
38+
return TexturePack.class.getResourceAsStream(location);
39+
}
40+
3641
return null;
3742
}
3843

@@ -57,13 +62,15 @@ public ModMetadata getModMetadata() {
5762
}
5863

5964
private Path getPath(String location) {
60-
for (Path root : roots) {
61-
String separator = root.getFileSystem().getSeparator();
62-
String pathName = location.replace("/", separator);
63-
Path path = root.resolve(pathName);
64-
65-
if (Files.exists(path)) {
66-
return path;
65+
if (!"/pack.png".equals(location) && !"/pack.txt".equals(location)) {
66+
for (Path root : roots) {
67+
String separator = root.getFileSystem().getSeparator();
68+
String pathName = location.replace("/", separator);
69+
Path path = root.resolve(pathName);
70+
71+
if (Files.exists(path)) {
72+
return path;
73+
}
6774
}
6875
}
6976

libraries/resource-loader/resource-loader-mc1.3-pre-07261249-mc13w07a/src/main/java/net/ornithemc/osl/resource/loader/impl/BuiltInModTexturePack.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.fabricmc.loader.api.metadata.ModMetadata;
1212

1313
import net.minecraft.client.resource.pack.AbstractTexturePack;
14+
import net.minecraft.client.resource.pack.TexturePack;
1415

1516
import net.ornithemc.osl.resource.loader.api.ModTexturePack;
1617

@@ -33,6 +34,10 @@ public InputStream getResource(String location) {
3334
Path path = getPath(location);
3435

3536
if (path == null || !Files.exists(path)) {
37+
if ("/pack.png".equals(location) || "/pack.txt".equals(location)) {
38+
return TexturePack.class.getResourceAsStream(location);
39+
}
40+
3641
return null;
3742
}
3843

@@ -62,13 +67,15 @@ public ModMetadata getModMetadata() {
6267
}
6368

6469
private Path getPath(String location) {
65-
for (Path root : roots) {
66-
String separator = root.getFileSystem().getSeparator();
67-
String pathName = location.replace("/", separator);
68-
Path path = root.resolve(pathName);
69-
70-
if (Files.exists(path)) {
71-
return path;
70+
if (!"/pack.png".equals(location) && !"/pack.txt".equals(location)) {
71+
for (Path root : roots) {
72+
String separator = root.getFileSystem().getSeparator();
73+
String pathName = location.replace("/", separator);
74+
Path path = root.resolve(pathName);
75+
76+
if (Files.exists(path)) {
77+
return path;
78+
}
7279
}
7380
}
7481

libraries/resource-loader/resource-loader-mc13w09a-mc1.5.2/src/main/java/net/ornithemc/osl/resource/loader/impl/BuiltInModTexturePack.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.fabricmc.loader.api.metadata.ModMetadata;
1212

1313
import net.minecraft.client.resource.pack.AbstractTexturePack;
14+
import net.minecraft.client.resource.pack.TexturePack;
1415

1516
import net.ornithemc.osl.resource.loader.api.ModTexturePack;
1617

@@ -33,6 +34,10 @@ public InputStream openResource(String location) {
3334
Path path = getPath(location);
3435

3536
if (path == null || !Files.exists(path)) {
37+
if ("/pack.png".equals(location) || "/pack.txt".equals(location)) {
38+
return TexturePack.class.getResourceAsStream(location);
39+
}
40+
3641
return null;
3742
}
3843

@@ -62,13 +67,15 @@ public ModMetadata getModMetadata() {
6267
}
6368

6469
private Path getPath(String location) {
65-
for (Path root : roots) {
66-
String separator = root.getFileSystem().getSeparator();
67-
String pathName = location.replace("/", separator);
68-
Path path = root.resolve(pathName);
69-
70-
if (Files.exists(path)) {
71-
return path;
70+
if (!"/pack.png".equals(location) && !"/pack.txt".equals(location)) {
71+
for (Path root : roots) {
72+
String separator = root.getFileSystem().getSeparator();
73+
String pathName = location.replace("/", separator);
74+
Path path = root.resolve(pathName);
75+
76+
if (Files.exists(path)) {
77+
return path;
78+
}
7279
}
7380
}
7481

0 commit comments

Comments
 (0)