public static File getResourcePackFile(AbstractResourcePack p_getResourcePackFile_0_) { if (directAccessValid) { try { return p_getResourcePackFile_0_.resourcePackFile; } catch (IllegalAccessError illegalaccesserror) { directAccessValid = false; if (!ForgeAbstractResourcePack_resourcePackFile.exists()) { throw illegalaccesserror; } } } return (File)Reflector.getFieldValue(p_getResourcePackFile_0_, ForgeAbstractResourcePack_resourcePackFile); }
public static String[] collectFiles(IResourcePack p_collectFiles_0_, String p_collectFiles_1_, String p_collectFiles_2_, String[] p_collectFiles_3_) { if (p_collectFiles_0_ instanceof DefaultResourcePack) { return collectFilesFixed(p_collectFiles_0_, p_collectFiles_3_); } else if (!(p_collectFiles_0_ instanceof AbstractResourcePack)) { return new String[0]; } else { AbstractResourcePack abstractresourcepack = (AbstractResourcePack)p_collectFiles_0_; File file1 = ResourceUtils.getResourcePackFile(abstractresourcepack); return file1 == null ? new String[0] : (file1.isDirectory() ? collectFilesFolder(file1, "", p_collectFiles_1_, p_collectFiles_2_) : (file1.isFile() ? collectFilesZIP(file1, p_collectFiles_1_, p_collectFiles_2_) : new String[0])); } }
public static String[] collectFiles(IResourcePack p_collectFiles_0_, String[] p_collectFiles_1_, String[] p_collectFiles_2_, String[] p_collectFiles_3_) { if (p_collectFiles_0_ instanceof DefaultResourcePack) { return collectFilesFixed(p_collectFiles_0_, p_collectFiles_3_); } else if (!(p_collectFiles_0_ instanceof AbstractResourcePack)) { return new String[0]; } else { AbstractResourcePack abstractresourcepack = (AbstractResourcePack)p_collectFiles_0_; File file1 = abstractresourcepack.resourcePackFile; return file1 == null ? new String[0] : (file1.isDirectory() ? collectFilesFolder(file1, "", p_collectFiles_1_, p_collectFiles_2_) : (file1.isFile() ? collectFilesZIP(file1, p_collectFiles_1_, p_collectFiles_2_) : new String[0])); } }
private static String[] collectFiles(IResourcePack p_collectFiles_0_, String p_collectFiles_1_, String p_collectFiles_2_) { if (p_collectFiles_0_ instanceof DefaultResourcePack) { return collectFilesDefault(p_collectFiles_0_); } else if (!(p_collectFiles_0_ instanceof AbstractResourcePack)) { return new String[0]; } else { AbstractResourcePack abstractresourcepack = (AbstractResourcePack)p_collectFiles_0_; File file1 = ResourceUtils.getResourcePackFile(abstractresourcepack); return file1 == null ? new String[0] : (file1.isDirectory() ? collectFilesFolder(file1, "", p_collectFiles_1_, p_collectFiles_2_) : (file1.isFile() ? collectFilesZIP(file1, p_collectFiles_1_, p_collectFiles_2_) : new String[0])); } }
private static void dedupeResourcePacks() { if (Boolean.getBoolean("fz.misc.dupedpacks")) return; Minecraft mc = Minecraft.getMinecraft(); HashSet<File> seen = new HashSet<File>(); int removed = 0; for (Iterator<IResourcePack> iter = mc.defaultResourcePacks.iterator(); iter.hasNext(); ) { IResourcePack pack = iter.next(); File packFile = null; if (pack instanceof AbstractResourcePack) { AbstractResourcePack arp = (AbstractResourcePack) pack; packFile = arp.resourcePackFile; } if (packFile == null) continue; if (seen.add(packFile)) continue; iter.remove(); removed++; } if (removed == 0) return; String thx = removed >= 10 ? " #you'rewelcome" : ""; Core.logWarning(removed + " duplicated resourcepacks were removed." + thx); }
/** * Dynamically generates a sound JSON file based on a resource pack's file structure. * * If it's a folder, then load it as a sound collection. * A sound collection falls under the same resource name. When called to play, it will pick a random sound from the collection to play it. * * If it's just a sound file, then load the sound file * * @param pack The resource pack to generate the sound JSON for. * @return The generated sound JSON. */ public static String generateSoundJSON(AbstractResourcePack pack) { StringWriter sw = new StringWriter(); try (JsonGenerator json = Json.createGenerator(sw);) { json.writeStartObject(); if (pack instanceof FileResourcePack) { //For zip resource packs try { generateSoundJSON((FileResourcePack) pack, json); } catch (Exception e) { Error error = new ExceptionInInitializerError("Error generating fake sound JSON file."); error.addSuppressed(e); throw error; } } else if (pack instanceof FolderResourcePack) { //For folder resource packs generateSoundJSON((FolderResourcePack) pack, json); } json.writeEnd().flush(); return sw.toString(); } }
public static File getResourcePackFile(AbstractResourcePack arp) { if (directAccessValid) { try { return arp.resourcePackFile; } catch (IllegalAccessError var2) { directAccessValid = false; if (!ForgeAbstractResourcePack_resourcePackFile.exists()) { throw var2; } } } return (File)Reflector.getFieldValue(arp, ForgeAbstractResourcePack_resourcePackFile); }
private static String[] collectFiles(IResourcePack rp, String prefix, String suffix) { if (rp instanceof DefaultResourcePack) { return collectFilesDefault(rp); } else if (!(rp instanceof AbstractResourcePack)) { return new String[0]; } else { AbstractResourcePack arp = (AbstractResourcePack)rp; File tpFile = ResourceUtils.getResourcePackFile(arp); return tpFile == null ? new String[0] : (tpFile.isDirectory() ? collectFilesFolder(tpFile, "", prefix, suffix) : (tpFile.isFile() ? collectFilesZIP(tpFile, prefix, suffix) : new String[0])); } }
public void func_110603_a(File p_110603_1_) { if(p_110603_1_.isDirectory()) { File[] var2 = p_110603_1_.listFiles(); int var3 = var2.length; for(int var4 = 0; var4 < var3; ++var4) { File var5 = var2[var4]; this.func_110603_a(var5); } } else { this.func_110604_a(AbstractResourcePack.func_110595_a(this.field_110607_c, p_110603_1_), p_110603_1_); } }
public static String[] collectFiles(IResourcePack p_collectFiles_0_, String[] p_collectFiles_1_, String[] p_collectFiles_2_, String[] p_collectFiles_3_) { if (p_collectFiles_0_ instanceof DefaultResourcePack) { return collectFilesFixed(p_collectFiles_0_, p_collectFiles_3_); } else { if (p_collectFiles_0_ instanceof LegacyV2Adapter) { IResourcePack iresourcepack = (IResourcePack)Reflector.getFieldValue(p_collectFiles_0_, Reflector.LegacyV2Adapter_pack); if (iresourcepack == null) { Config.warn("LegacyV2Adapter base resource pack not found: " + p_collectFiles_0_); return new String[0]; } p_collectFiles_0_ = iresourcepack; } if (!(p_collectFiles_0_ instanceof AbstractResourcePack)) { Config.warn("Unknown resource pack type: " + p_collectFiles_0_); return new String[0]; } else { AbstractResourcePack abstractresourcepack = (AbstractResourcePack)p_collectFiles_0_; File file1 = abstractresourcepack.resourcePackFile; if (file1 == null) { return new String[0]; } else if (file1.isDirectory()) { return collectFilesFolder(file1, "", p_collectFiles_1_, p_collectFiles_2_); } else if (file1.isFile()) { return collectFilesZIP(file1, p_collectFiles_1_, p_collectFiles_2_); } else { Config.warn("Unknown resource pack file: " + file1); return new String[0]; } } } }
public MetadataSection func_135058_a(MetadataSerializer p_135058_1_, String p_135058_2_) throws IOException { return AbstractResourcePack.func_110596_a(p_135058_1_, DefaultResourcePack.class.getResourceAsStream("/" + (new ResourceLocation("pack.mcmeta")).func_110623_a()), p_135058_2_); }