use of net.minecraftforge.fml.common.LoaderException in project MinecraftForge by MinecraftForge.
the class FMLClientHandler method beginMinecraftLoading.
/**
* Called to start the whole game off
*
* @param minecraft The minecraft instance being launched
* @param resourcePackList The resource pack list we will populate with mods
* @param resourceManager The resource manager
*/
@SuppressWarnings("unchecked")
public void beginMinecraftLoading(Minecraft minecraft, List<IResourcePack> resourcePackList, IReloadableResourceManager resourceManager, MetadataSerializer metaSerializer) {
detectOptifine();
SplashProgress.start();
client = minecraft;
this.resourcePackList = resourcePackList;
this.metaSerializer = metaSerializer;
this.resourcePackMap = Maps.newHashMap();
if (minecraft.isDemo()) {
FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
haltGame("FML will not run in demo mode", new RuntimeException());
return;
}
List<String> injectedModContainers = FMLCommonHandler.instance().beginLoading(this);
try {
Loader.instance().loadMods(injectedModContainers);
} catch (WrongMinecraftVersionException wrong) {
wrongMC = wrong;
} catch (DuplicateModsFoundException dupes) {
dupesFound = dupes;
} catch (Java8VersionException j8mods) {
j8onlymods = j8mods;
} catch (MissingModsException missing) {
modsMissing = missing;
} catch (ModSortingException sorting) {
modSorting = sorting;
} catch (CustomModLoadingErrorDisplayException custom) {
FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt");
customError = custom;
} catch (MultipleModsErrored multiple) {
multipleModsErrored = multiple;
} catch (LoaderException le) {
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
} finally {
client.refreshResources();
}
try {
Loader.instance().preinitializeMods();
} catch (CustomModLoadingErrorDisplayException custom) {
FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt");
customError = custom;
} catch (LoaderException le) {
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
}
Map<String, Map<String, String>> sharedModList = (Map<String, Map<String, String>>) Launch.blackboard.get("modList");
if (sharedModList == null) {
sharedModList = Maps.newHashMap();
Launch.blackboard.put("modList", sharedModList);
}
for (ModContainer mc : Loader.instance().getActiveModList()) {
Map<String, String> sharedModDescriptor = mc.getSharedModDescriptor();
if (sharedModDescriptor != null) {
String sharedModId = "fml:" + mc.getModId();
sharedModList.put(sharedModId, sharedModDescriptor);
}
}
}
use of net.minecraftforge.fml.common.LoaderException in project MinecraftForge by MinecraftForge.
the class DirectoryDiscoverer method exploreFileSystem.
public void exploreFileSystem(String path, File modDir, List<ModContainer> harvestedMods, ModCandidate candidate, @Nullable MetadataCollection mc) {
if (path.length() == 0) {
File metadata = new File(modDir, "mcmod.info");
try {
FileInputStream fis = new FileInputStream(metadata);
try {
mc = MetadataCollection.from(fis, modDir.getName());
} finally {
IOUtils.closeQuietly(fis);
}
FMLLog.fine("Found an mcmod.info file in directory %s", modDir.getName());
} catch (Exception e) {
mc = MetadataCollection.from(null, "");
FMLLog.fine("No mcmod.info file found in directory %s", modDir.getName());
}
}
File[] content = modDir.listFiles(new ClassFilter());
// Always sort our content
Arrays.sort(content);
for (File file : content) {
if (file.isDirectory()) {
FMLLog.finer("Recursing into package %s", path + file.getName());
exploreFileSystem(path + file.getName() + "/", file, harvestedMods, candidate, mc);
continue;
}
Matcher match = classFile.matcher(file.getName());
if (match.matches()) {
ASMModParser modParser = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
modParser = new ASMModParser(fis);
candidate.addClassEntry(path + file.getName());
} catch (LoaderException e) {
FMLLog.log(Level.ERROR, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath());
throw e;
} catch (Exception e) {
throw Throwables.propagate(e);
} finally {
IOUtils.closeQuietly(fis);
}
modParser.validate();
modParser.sendToTable(table, candidate);
ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate);
if (container != null) {
harvestedMods.add(container);
container.bindMetadata(mc);
}
}
}
}
use of net.minecraftforge.fml.common.LoaderException in project MinecraftForge by MinecraftForge.
the class FMLClientHandler method finishMinecraftLoading.
/**
* Called a bit later on during initialization to finish loading mods
* Also initializes key bindings
*
*/
public void finishMinecraftLoading() {
if (modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null || j8onlymods != null || multipleModsErrored != null) {
SplashProgress.finish();
return;
}
try {
Loader.instance().initializeMods();
} catch (CustomModLoadingErrorDisplayException custom) {
FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt");
customError = custom;
SplashProgress.finish();
return;
} catch (LoaderException le) {
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
}
// Reload resources
client.refreshResources();
RenderingRegistry.loadEntityRenderers(Minecraft.getMinecraft().getRenderManager().entityRenderMap);
guiFactories = HashBiMap.create();
for (ModContainer mc : Loader.instance().getActiveModList()) {
String className = mc.getGuiClassName();
if (Strings.isNullOrEmpty(className)) {
continue;
}
try {
Class<?> clazz = Class.forName(className, true, Loader.instance().getModClassLoader());
Class<? extends IModGuiFactory> guiClassFactory = clazz.asSubclass(IModGuiFactory.class);
IModGuiFactory guiFactory = guiClassFactory.newInstance();
guiFactory.initialize(client);
guiFactories.put(mc, guiFactory);
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "A critical error occurred instantiating the gui factory for mod %s", mc.getModId());
}
}
loading = false;
//Reload options to load any mod added keybindings.
client.gameSettings.loadOptions();
Loader.instance().loadingComplete();
SplashProgress.finish();
}
use of net.minecraftforge.fml.common.LoaderException in project MinecraftForge by MinecraftForge.
the class ConfigManager method load.
public static void load(String modid, Config.Type type) {
FMLLog.fine("Attempting to inject @Config classes into %s for type %s", modid, type);
ClassLoader mcl = Loader.instance().getModClassLoader();
File configDir = Loader.instance().getConfigDir();
Multimap<Config.Type, ASMData> map = asm_data.get(modid);
if (map == null)
return;
for (ASMData targ : map.get(type)) {
try {
Class<?> cls = Class.forName(targ.getClassName(), true, mcl);
String name = (String) targ.getAnnotationInfo().get("name");
if (name == null)
name = modid;
String category = (String) targ.getAnnotationInfo().get("category");
if (category == null)
category = "general";
File file = new File(configDir, name + ".cfg");
Configuration cfg = CONFIGS.get(file.getAbsolutePath());
if (cfg == null) {
cfg = new Configuration(file);
cfg.load();
CONFIGS.put(file.getAbsolutePath(), cfg);
}
createConfig(cfg, cls, modid, type == Config.Type.INSTANCE, category);
cfg.save();
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "An error occurred trying to load a config for %s into %s", modid, targ.getClassName());
throw new LoaderException(e);
}
}
}
use of net.minecraftforge.fml.common.LoaderException in project MinecraftForge by MinecraftForge.
the class JarDiscoverer method discover.
@Override
public List<ModContainer> discover(ModCandidate candidate, ASMDataTable table) {
List<ModContainer> foundMods = Lists.newArrayList();
FMLLog.fine("Examining file %s for potential mods", candidate.getModContainer().getName());
JarFile jar = null;
try {
jar = new JarFile(candidate.getModContainer());
ZipEntry modInfo = jar.getEntry("mcmod.info");
MetadataCollection mc = null;
if (modInfo != null) {
FMLLog.finer("Located mcmod.info file in file %s", candidate.getModContainer().getName());
InputStream inputStream = jar.getInputStream(modInfo);
try {
mc = MetadataCollection.from(inputStream, candidate.getModContainer().getName());
} finally {
IOUtils.closeQuietly(inputStream);
}
} else {
FMLLog.fine("The mod container %s appears to be missing an mcmod.info file", candidate.getModContainer().getName());
mc = MetadataCollection.from(null, "");
}
for (ZipEntry ze : Collections.list(jar.entries())) {
if (ze.getName() != null && ze.getName().startsWith("__MACOSX")) {
continue;
}
Matcher match = classFile.matcher(ze.getName());
if (match.matches()) {
ASMModParser modParser;
try {
InputStream inputStream = jar.getInputStream(ze);
try {
modParser = new ASMModParser(inputStream);
} finally {
IOUtils.closeQuietly(inputStream);
}
candidate.addClassEntry(ze.getName());
} catch (LoaderException e) {
FMLLog.log(Level.ERROR, e, "There was a problem reading the entry %s in the jar %s - probably a corrupt zip", ze.getName(), candidate.getModContainer().getPath());
jar.close();
throw e;
}
modParser.validate();
modParser.sendToTable(table, candidate);
ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate);
if (container != null) {
table.addContainer(container);
foundMods.add(container);
container.bindMetadata(mc);
container.setClassVersion(modParser.getClassVersion());
}
}
}
} catch (Exception e) {
FMLLog.log(Level.WARN, e, "Zip file %s failed to read properly, it will be ignored", candidate.getModContainer().getName());
} finally {
Java6Utils.closeZipQuietly(jar);
}
return foundMods;
}
Aggregations