From 40bdde204321a3903ec28bf20f8bc7af92df5ad9 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 17 Jun 2019 14:08:16 -0700 Subject: [PATCH] Fix Vanilla resources loading from classpath, instead of the extra jar. Causing issues in dev time, and Forge replacements. Closes #5824 --- .../resources/VanillaPack.java.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 patches/minecraft/net/minecraft/resources/VanillaPack.java.patch diff --git a/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch b/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch new file mode 100644 index 0000000000..633066f062 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/VanillaPack.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/resources/VanillaPack.java ++++ b/net/minecraft/resources/VanillaPack.java +@@ -184,7 +184,7 @@ + + try { + URL url = VanillaPack.class.getResource(s); +- return url != null && FolderPack.func_195777_a(new File(url.getFile()), s) ? VanillaPack.class.getResourceAsStream(s) : null; ++ return url != null && FolderPack.func_195777_a(new File(url.getFile()), s) ? getExtraInputStream(p_195782_1_, s) : null; + } catch (IOException var6) { + return VanillaPack.class.getResourceAsStream(s); + } +@@ -192,7 +192,7 @@ + + @Nullable + protected InputStream func_200010_a(String p_200010_1_) { +- return VanillaPack.class.getResourceAsStream("/" + p_200010_1_); ++ return getExtraInputStream(ResourcePackType.SERVER_DATA, "/" + p_200010_1_); + } + + public boolean func_195764_b(ResourcePackType p_195764_1_, ResourceLocation p_195764_2_) { +@@ -222,4 +222,18 @@ + + public void close() { + } ++ ++ //Vanilla used to just grab from the classpath, this breaks dev environments, and Forge runtime ++ //as forge ships vanilla assets in an 'extra' jar with no classes. ++ //So find that extra jar using the .mcassetsroot marker. ++ private InputStream getExtraInputStream(ResourcePackType type, String resource) { ++ try { ++ FileSystem fs = field_217810_e.get(type); ++ if (fs != null) ++ return Files.newInputStream(fs.getPath(resource)); ++ return VanillaPack.class.getResourceAsStream(resource); ++ } catch (IOException e) { ++ return VanillaPack.class.getResourceAsStream(resource); ++ } ++ } + }