Skip to content

Commit 86695c5

Browse files
anatawa12Kai-Z-JP
andcommitted
[Fix] Getting InputStream from ResourceLocation was incorrect
See also: Kai-Z-JP/KaizPatchX#127, Kai-Z-JP/KaizPatchX@b4828cd Co-authored-by: Kaiz <[email protected]>
1 parent 62612f7 commit 86695c5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/main/ngtlib-patches/jp/ngt/ngtlib/io/NGTFileLoader.java.patch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,30 @@
4747
}
4848

4949
private static JFileChooser getCustomChooser(String title) {
50+
@@ -231,23 +222,13 @@
51+
return null;
52+
}
53+
}
54+
55+
public static InputStream getInputStream(ResourceLocation par1) throws IOException {
56+
- if (!NGTCore.proxy.isServer()) {
57+
- return NGTUtilClient.getMinecraft().getResourceManager().getResource(par1).getInputStream();
58+
- } else {
59+
- int i = par1.getPath().lastIndexOf("/");
60+
- String s = par1.getPath().substring(i + 1);
61+
- List<File> list = findFile((FileMatcher)((filex) -> filex.getName().equals(s)));
62+
- if (list.isEmpty()) {
63+
- throw new FileNotFoundException("On get stream : " + s);
64+
- } else {
65+
- File file1 = list.get(0);
66+
- return getInputStreamFromFile(file1);
67+
- }
68+
- }
69+
+ return NGTCore.proxy.isServer()
70+
+ ? com.anatawa12.fixRtm.io.FIXFileLoader.INSTANCE.getInputStream(par1)
71+
+ : NGTUtilClient.getMinecraft().getResourceManager().getResource(par1).getInputStream();
72+
}
73+
74+
public static InputStream getInputStreamFromFile(File file) throws IOException {
75+
String s = getArchiveSuffix(file.getAbsolutePath());
76+
return (InputStream)(!s.isEmpty() ? getStreamFromArchive(file, s) : new FileInputStream(file));

0 commit comments

Comments
 (0)