public ResourceProxy() { super(Loader.instance().activeModContainer().getSource()); overrides.put("pack.mcmeta", "/proxypack.mcmeta"); }
public static Set<String> getContainingMods(File file) { Set<String> modIds = Sets.newHashSet(); for (ModContainer container : Loader.instance().getModList()) { if (container.getSource().equals(file)) { modIds.add(container.getModId()); } } return modIds; }
@SuppressWarnings("UnusedDeclaration") @EventHandler public void init(@SuppressWarnings("UnusedParameters") FMLInitializationEvent event) { ModContainer thisMod = Loader.instance().getIndexedModList().get(ModInfo.MODID); if(thisMod != null) { String fileName = thisMod.getSource().getName(); if(fileName.contains("-dev") || !fileName.contains(".jar")) { ModInfo.DEBUG_MODE = true; MinerLogger.debug("Enabling debug mode"); } } }
private static Map<File, Set<ModContainer>> makeModMap() { Map<File, Set<ModContainer>> modMap = new HashMap<>(); for (ModContainer mod : Loader.instance().getModList()) { Set<ModContainer> currentMods = modMap.getOrDefault(mod.getSource(), new HashSet<>()); currentMods.add(mod); try { modMap.put(mod.getSource().getCanonicalFile(), currentMods); } catch (IOException e) { throw new RuntimeException(e); } } try { modMap.remove(Loader.instance().getMinecraftModContainer().getSource()); // Ignore minecraft jar (minecraft) modMap.remove(Loader.instance().getIndexedModList().get("FML").getSource()); // Ignore forge jar (FML, forge) } catch (NullPointerException ignored) { // Workaround for https://github.com/MinecraftForge/MinecraftForge/issues/4919 } return modMap; }
public CustomEmoteIconResourcePack() { super(Loader.instance().activeModContainer().getSource()); }
private void collectFilesFromModContainers(ASMDataTable table) { final File dummyEntry = new File("minecraft.jar"); // dummy entry comes from MCP container for (ModContainer c : Loader.instance().getModList()) { File f = c.getSource(); if (f != null && !f.equals(dummyEntry) && !f.isDirectory()) { FileMeta meta = getOrCreateData(f); meta.mods.put(c.getModId(), new ModMeta(c)); } } }
public static void load(Predicate<IRegistryDataParser> include) { //noinspection ConstantConditions ModContainer awModContainer = Loader.instance().activeModContainer(); Path registryOverridesFolder = new File(AWCoreStatics.configPathForFiles + "registry").toPath(); if (registryOverridesFolder.toFile().exists()) { //noinspection ConstantConditions loadRegistries(awModContainer, registryOverridesFolder, include); } //noinspection ConstantConditions loadRegistries(awModContainer, awModContainer.getSource(), "assets/" + awModContainer.getModId() + "/registry", include); }
public void loadTemplates() { int loadedCount = 0; if (AWStructureStatics.loadDefaultPack) { //noinspection ConstantConditions loadedCount += loadTemplatesFromSource(Loader.instance().activeModContainer().getSource(), DEFAULT_TEMPLATE_DIRECTORY, false); } loadedCount += loadTemplatesFromSource(new File(INCLUDE_DIRECTORY), "", true); AncientWarfareStructure.LOG.info("Loaded " + loadedCount + " structure(s)"); validateTownTemplates(); }
public void loadSkins() { //noinspection ConstantConditions loadSkinsFromSource(Loader.instance().activeModContainer().getSource(), DEFAULT_SKINS); loadSkinsFromSource(new File(SKINS_CONFIG_PATH), ""); }
modClassLoader.addFile(mod.getSource()); } catch (MalformedURLException e) { throw new RuntimeException(e);
if (!EnderIOAPIProps.VERSION.equals(apiVersionString)) { result.add(" * Another mod is shipping a version of our API that doesn't match our version (" + apiVersionString + " from " + modContainer.getSource().getName() + "). That may not actually work."); } else if (modContainer.getSource().getName() != null && (!modContainer.getSource().getName().startsWith("EnderIO") && !modContainer.getSource().getName().startsWith("enderio") && !modContainer.getSource().getName().equals("bin"))) { result.add(" * Our API got loaded from " + modContainer.getSource().getName() + ". That's unexpected.");
private static boolean loadTextureFromAssets(ResourceLocation loc, String path) { //noinspection ConstantConditions String fullPath = "assets/" + AncientWarfareCore.MOD_ID + "/" + path; File source = Loader.instance().activeModContainer().getSource(); if (source.isFile()) { try (FileSystem fs = FileSystems.newFileSystem(source.toPath(), null)) { InputStream inputstream = fs.provider().newInputStream(fs.getPath(fullPath)); Minecraft.getMinecraft().renderEngine.loadTexture(loc, new TextureImageBased(loc, ImageIO.read(inputstream))); return true; } catch (IOException e) { //noop } } else if (source.isDirectory()) { File file = source.toPath().resolve(fullPath).toFile(); if (loadTexture(loc, file)) { return true; } } return false; } }
@SuppressWarnings("unused") @EventHandler public void init(@SuppressWarnings("UnusedParameters") FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); ModContainer thisMod = Loader.instance().getIndexedModList().get(ModInfo.MOD_ID); if(thisMod != null) { String fileName = thisMod.getSource().getName(); if(fileName.contains("-dev") || !fileName.contains(".jar")) { debugMode = true; devLog("DEV VERSION"); } } forceConsumerAvailable = false; if(AUTODETECT_TOOLS_TOGGLE) { addTools(); } }
private void reloadSounds() { SoundHandler sndHandler = Minecraft.getMinecraft().getSoundHandler(); Set<String> sounds = new HashSet<>(); //noinspection ConstantConditions FileUtils.findFiles(Loader.instance().activeModContainer().getSource(), DEFAULT_SOUNDS_DIRECTORY, (root, file) -> { String extension = FilenameUtils.getExtension(file.toString()); if (extension.equals("ogg")) { String relative = root.relativize(file).toString(); sounds.add(AncientWarfareStructure.MOD_ID + ":auto_load/" + FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/")); } }); ProgressManager.ProgressBar resourcesBar = ProgressManager.push("Loading AW sounds", sounds.size()); sounds.forEach(s -> { ResourceLocation location = new ResourceLocation(s); //noinspection ConstantConditions loadSoundResource(sndHandler, location, new SoundList(Collections.singletonList( new Sound(s, 1, 1, 1, Sound.Type.FILE, false)), false, null)); if (!((IForgeRegistryModifiable)ForgeRegistries.SOUND_EVENTS).isLocked()) { ForgeRegistries.SOUND_EVENTS.register(new SoundEvent(location).setRegistryName(location)); } resourcesBar.step(s); } ); ProgressManager.pop(resourcesBar); }
public static void loadRecipes() { ModContainer awModContainer = Loader.instance().activeModContainer(); //noinspection ConstantConditions loadRecipes(awModContainer, new File(AWCoreStatics.configPathForFiles + "research_recipes"), ""); Loader.instance().getActiveModList().forEach(m -> AWCraftingManager.loadRecipes(m, m.getSource(), "assets/" + m.getModId() + "/research_recipes")); Loader.instance().setActiveModContainer(awModContainer); }
case 4: if(selectedMod.getLatest() != null) { File mcSource = selectedMod.getMc().getSource(); String filename = selectedMod.getFileName(Loader.MC_VERSION); File newFile = new File(mcSource.getParent(), filename);