diff --git a/fml/client/cpw/mods/fml/client/SpriteHelper.java b/fml/client/cpw/mods/fml/client/SpriteHelper.java index e65439e6a4..0c2a6133f2 100644 --- a/fml/client/cpw/mods/fml/client/SpriteHelper.java +++ b/fml/client/cpw/mods/fml/client/SpriteHelper.java @@ -80,7 +80,7 @@ public class SpriteHelper initMCSpriteMaps(); } if (spriteInfo.containsKey(file)) { - FMLCommonHandler.instance().getFMLLogger().finer(String.format("Duplicate attempt to register a sprite file %s for overriding -- ignoring",file)); + FMLLog.log("fml.TextureManager", Level.FINE, "Duplicate attempt to register a sprite file %s for overriding -- ignoring",file); return; } spriteInfo.put(file, toBitSet(spriteMap)); @@ -98,7 +98,7 @@ public class SpriteHelper if (slots == null) { Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path)); - FMLLog.log(Level.SEVERE, ex, "A critical error has been detected with sprite overrides"); + FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "A critical error has been detected with sprite overrides"); FMLCommonHandler.instance().raiseException(ex,"Invalid request to getUniqueSpriteIndex",true); } @@ -107,7 +107,7 @@ public class SpriteHelper if (ret == -1) { Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path)); - FMLLog.log(Level.SEVERE, ex, "There are no sprite indicies left for %s", path); + FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "There are no sprite indicies left for %s", path); FMLCommonHandler.instance().raiseException(ex,"No more sprite indicies left", true); } return ret; diff --git a/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java b/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java index 6312484b72..4d3016653c 100644 --- a/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java +++ b/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java @@ -57,38 +57,38 @@ public class ModLoaderClientHelper implements IModLoaderSidedHelper public static void handleFinishLoadingFor(ModLoaderModContainer mc, Minecraft game) { - FMLLog.finer("Handling post startup activities for ModLoader mod %s", mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINE, "Handling post startup activities for ModLoader mod %s", mc.getModId()); BaseMod mod = (BaseMod) mc.getMod(); Map, Render> renderers = Maps.newHashMap(RenderManager.field_78727_a.field_78729_o); try { - FMLLog.finest("Requesting renderers from basemod %s", mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINEST, "Requesting renderers from basemod %s", mc.getModId()); mod.addRenderer(renderers); - FMLLog.finest("Received %d renderers from basemod %s", renderers.size(), mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINEST, "Received %d renderers from basemod %s", renderers.size(), mc.getModId()); } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "A severe problem was detected with the mod %s during the addRenderer call. Continuing, but expect odd results", mc.getModId()); + FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the addRenderer call. Continuing, but expect odd results", mc.getModId()); } MapDifference, Render> difference = Maps.difference(RenderManager.field_78727_a.field_78729_o, renderers, Equivalences.identity()); for ( Entry, Render> e : difference.entriesOnlyOnLeft().entrySet()) { - FMLLog.warning("The mod %s attempted to remove an entity renderer %s from the entity map. This will be ignored.", mc.getModId(), e.getKey().getName()); + FMLLog.log(mc.getModId(), Level.WARNING, "The mod %s attempted to remove an entity renderer %s from the entity map. This will be ignored.", mc.getModId(), e.getKey().getName()); } for (Entry, Render> e : difference.entriesOnlyOnRight().entrySet()) { - FMLLog.finest("Registering ModLoader entity renderer %s as instance of %s", e.getKey().getName(), e.getValue().getClass().getName()); + FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity renderer %s as instance of %s", e.getKey().getName(), e.getValue().getClass().getName()); RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue()); } for (Entry, ValueDifference> e : difference.entriesDiffering().entrySet()) { - FMLLog.finest("Registering ModLoader entity rendering override for %s as instance of %s", e.getKey().getName(), e.getValue().rightValue().getClass().getName()); + FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity rendering override for %s as instance of %s", e.getKey().getName(), e.getValue().rightValue().getClass().getName()); RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue().rightValue()); } @@ -98,7 +98,7 @@ public class ModLoaderClientHelper implements IModLoaderSidedHelper } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "A severe problem was detected with the mod %s during the registerAnimation call. Continuing, but expect odd results", mc.getModId()); + FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the registerAnimation call. Continuing, but expect odd results", mc.getModId()); } } diff --git a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java index 760d7f3faa..0495227128 100644 --- a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java +++ b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java @@ -40,12 +40,14 @@ public class FMLRenderAccessLibrary { public static Logger getLogger() { - return FMLLog.getLogger(); + Logger l = Logger.getLogger("FMLRenderAccessLibrary"); + l.setParent(FMLLog.getLogger()); + return l; } public static void log(Level level, String message) { - FMLLog.log(level, message); + FMLLog.log("FMLRenderAccessLibrary", level, message); } public static void log(Level level, String message, Throwable throwable) diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 1c579ab90e..6d48cb2125 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; import net.minecraft.crash.CrashReport; @@ -94,10 +95,10 @@ public class FMLCommonHandler public void beginLoading(IFMLSidedHandler handler) { sidedDelegate = handler; - FMLLog.info("Attempting early MinecraftForge initialization"); + FMLLog.log("MinecraftForge", Level.INFO, "Attempting early MinecraftForge initialization"); callForgeMethod("initialize"); callForgeMethod("registerCrashCallable"); - FMLLog.info("Completed early MinecraftForge initialization"); + FMLLog.log("MinecraftForge", Level.INFO, "Completed early MinecraftForge initialization"); } public void rescheduleTicks(Side side) @@ -191,7 +192,7 @@ public class FMLCommonHandler */ public void raiseException(Throwable exception, String message, boolean stopGame) { - FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception); + FMLLog.log(Level.SEVERE, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame); if (stopGame) { getSidedDelegate().haltGame(message,exception); @@ -453,6 +454,10 @@ public class FMLCommonHandler public boolean shouldServerBeKilledQuietly() { + if (sidedDelegate == null) + { + return false; + } return sidedDelegate.shouldServerShouldBeKilledQuietly(); } diff --git a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java index 37edd2ce69..d9048d1e65 100644 --- a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java @@ -18,6 +18,7 @@ import java.security.cert.Certificate; import java.util.Arrays; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -96,12 +97,12 @@ public class FMLDummyContainer extends DummyModContainer implements WorldAccessC ModContainer container = Loader.instance().getIndexedModList().get(modId); if (container == null) { - FMLLog.severe("This world was saved with mod %s which appears to be missing, things may not work well", modId); + FMLLog.log("fml.ModTracker", Level.SEVERE, "This world was saved with mod %s which appears to be missing, things may not work well", modId); continue; } if (!modVersion.equals(container.getVersion())) { - FMLLog.info("This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); + FMLLog.log("fml.ModTracker", Level.INFO, "This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); } } } diff --git a/fml/common/cpw/mods/fml/common/FMLLog.java b/fml/common/cpw/mods/fml/common/FMLLog.java index f9e6d676df..cf8dba8c58 100644 --- a/fml/common/cpw/mods/fml/common/FMLLog.java +++ b/fml/common/cpw/mods/fml/common/FMLLog.java @@ -7,11 +7,21 @@ public class FMLLog { private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log; + public static void log(String logChannel, Level level, String format, Object... data) + { + coreLog.log(logChannel, level, format, data); + } + public static void log(Level level, String format, Object... data) { coreLog.log(level, format, data); } + public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) + { + coreLog.log(logChannel, level, ex, format, data); + } + public static void log(Level level, Throwable ex, String format, Object... data) { coreLog.log(level, ex, format, data); @@ -50,4 +60,9 @@ public class FMLLog { return coreLog.getLogger(); } + + public static void makeLog(String logChannel) + { + coreLog.makeLog(logChannel); + } } diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java index 252aea20c5..7fe9565c4d 100644 --- a/fml/common/cpw/mods/fml/common/FMLModContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java @@ -164,15 +164,15 @@ public class FMLModContainer implements ModContainer modMetadata.requiredMods = requirements; modMetadata.dependencies = dependencies; modMetadata.dependants = dependants; - FMLLog.finest("Parsed dependency info : %s %s %s", requirements, dependencies, dependants); + FMLLog.log(getModId(), Level.FINEST, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants); } else { - FMLLog.finest("Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); + FMLLog.log(getModId(), Level.FINEST, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); } if (Strings.isNullOrEmpty(modMetadata.name)) { - FMLLog.info("Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId()); + FMLLog.log(getModId(), Level.INFO,"Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId()); modMetadata.name = getModId(); } internalVersion = (String) descriptor.get("version"); @@ -182,18 +182,18 @@ public class FMLModContainer implements ModContainer if (versionProps != null) { internalVersion = versionProps.getProperty(getModId()+".version"); - FMLLog.fine("Found version %s for mod %s in version.properties, using", internalVersion, getModId()); + FMLLog.log(getModId(), Level.FINE, "Found version %s for mod %s in version.properties, using", internalVersion, getModId()); } } if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version)) { - FMLLog.warning("Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version); + FMLLog.log(getModId(), Level.WARNING, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version); internalVersion = modMetadata.version; } if (Strings.isNullOrEmpty(internalVersion)) { - FMLLog.warning("Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); + FMLLog.log(getModId(), Level.WARNING, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); modMetadata.version = internalVersion = "1.0"; } @@ -212,7 +212,7 @@ public class FMLModContainer implements ModContainer { try { - FMLLog.fine("Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); + FMLLog.log(getModId(), Level.FINE,"Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); Properties version = null; if (getSource().isFile()) { @@ -241,7 +241,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.fine("Failed to find a usable version.properties file"); + FMLLog.log(getModId(), Level.FINEST, "Failed to find a usable version.properties file"); return null; } } @@ -293,7 +293,7 @@ public class FMLModContainer implements ModContainer { if (this.enabled) { - FMLLog.fine("Enabling mod %s", getModId()); + FMLLog.log(getModId(), Level.FINE, "Enabling mod %s", getModId()); this.eventBus = bus; this.controller = controller; eventBus.register(this); @@ -324,7 +324,7 @@ public class FMLModContainer implements ModContainer } else { - FMLLog.severe("The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes)); + FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes)); } } } @@ -388,7 +388,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(Level.WARNING, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); + FMLLog.log(getModId(), Level.WARNING, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); } } if (f != null) @@ -399,7 +399,7 @@ public class FMLModContainer implements ModContainer target = modInstance; if (!modInstance.getClass().equals(clz)) { - FMLLog.warning("Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); + FMLLog.log(getModId(), Level.WARNING, "Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); continue; } } @@ -445,7 +445,7 @@ public class FMLModContainer implements ModContainer { warnLevel = Level.FINER; } - FMLLog.log(warnLevel, "The mod %s is expecting signature %s for source %s, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); + FMLLog.log(getModId(), warnLevel, "The mod %s is expecting signature %s for source %s, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); } else { diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java index 123e9962ac..c9f1cb9ce5 100644 --- a/fml/common/cpw/mods/fml/common/LoadController.java +++ b/fml/common/cpw/mods/fml/common/LoadController.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; +import java.util.logging.Logger; import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; @@ -60,14 +61,16 @@ public class LoadController boolean isActive = mod.registerBus(bus, this); if (isActive) { - FMLLog.fine("Activating mod %s", mod.getModId()); + Level level = Logger.getLogger(mod.getModId()).getLevel(); + FMLLog.log(mod.getModId(), Level.FINE, "Mod Logging channel %s configured at %s level.", level == null ? "default" : level); + FMLLog.log(mod.getModId(), Level.INFO, "Activating mod %s", mod.getModId()); activeModList.add(mod); modStates.put(mod.getModId(), ModState.UNLOADED); eventBus.put(mod.getModId(), bus); } else { - FMLLog.warning("Mod %s has been disabled through configuration", mod.getModId()); + FMLLog.log(mod.getModId(), Level.WARNING, "Mod %s has been disabled through configuration", mod.getModId()); modStates.put(mod.getModId(), ModState.UNLOADED); modStates.put(mod.getModId(), ModState.DISABLED); } @@ -95,19 +98,29 @@ public class LoadController StringBuilder sb = new StringBuilder(); printModStates(sb); FMLLog.getLogger().severe(sb.toString()); - FMLLog.severe("The following problems were captured during this phase"); - for (Entry error : errors.entries()) + if (errors.size()>0) { - FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey()); - if (error.getValue() instanceof IFMLHandledException) + FMLLog.severe("The following problems were captured during this phase"); + for (Entry error : errors.entries()) { - toThrow = error.getValue(); - } - else if (toThrow == null) - { - toThrow = error.getValue(); + FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey()); + if (error.getValue() instanceof IFMLHandledException) + { + toThrow = error.getValue(); + } + else if (toThrow == null) + { + toThrow = error.getValue(); + } } } + else + { + FMLLog.severe("The ForgeModLoader state engine has become corrupted. Probably, a state was missed by and invalid modification to a base class" + + "ForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside of" + + "ForgeModLoader, especially Optifine, to see if there are fixes available."); + throw new RuntimeException("The ForgeModLoader state engine is invalid"); + } if (toThrow != null && toThrow instanceof RuntimeException) { throw (RuntimeException)toThrow; @@ -136,9 +149,9 @@ public class LoadController activeContainer = mc; String modId = mc.getModId(); stateEvent.applyModContainer(activeContainer()); - FMLLog.finer("Sending event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId); eventChannels.get(modId).post(stateEvent); - FMLLog.finer("Sent event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId); activeContainer = null; if (stateEvent instanceof FMLStateEvent) { diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index e212775a07..a48a775443 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -27,7 +27,6 @@ import java.util.concurrent.Callable; import java.util.logging.Level; import net.minecraft.crash.CallableMinecraftVersion; -import net.minecraft.server.MinecraftServer; import com.google.common.base.CharMatcher; import com.google.common.base.Function; @@ -62,6 +61,7 @@ import cpw.mods.fml.common.toposort.ModSortingException; import cpw.mods.fml.common.toposort.TopologicalSort; import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.VersionParser; +import cpw.mods.fml.relauncher.FMLRelaunchLog; /** * The loader class performs the actual loading of the mod code from disk. @@ -143,6 +143,7 @@ public class Loader private static File minecraftDir; private static List injectedContainers; + private File loggingProperties; public static Loader instance() { @@ -187,7 +188,7 @@ public class Loader */ private void sortModList() { - FMLLog.fine("Verifying mod requirements are satisfied"); + FMLLog.finer("Verifying mod requirements are satisfied"); try { BiMap modVersions = HashBiMap.create(); @@ -239,13 +240,13 @@ public class Loader } } - FMLLog.fine("All mod requirements are satisfied"); + FMLLog.finer("All mod requirements are satisfied"); ModSorter sorter = new ModSorter(getActiveModList(), namedMods); try { - FMLLog.fine("Sorting mods into an ordered list"); + FMLLog.finer("Sorting mods into an ordered list"); List sortedMods = sorter.sort(); // Reset active list to the sorted list modController.getActiveModList().clear(); @@ -254,7 +255,7 @@ public class Loader mods.removeAll(sortedMods); sortedMods.addAll(mods); mods = sortedMods; - FMLLog.fine("Mod sorting completed successfully"); + FMLLog.finer("Mod sorting completed successfully"); } catch (ModSortingException sortException) { @@ -267,17 +268,19 @@ public class Loader } finally { - FMLLog.fine("Mod sorting data:"); + FMLLog.fine("Mod sorting data"); + int unprintedMods = mods.size(); for (ModContainer mod : getActiveModList()) { if (!mod.isImmutable()) { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), mod.getSortingRules()); + unprintedMods--; } } - if (mods.size()==0) + if (unprintedMods == mods.size()) { - FMLLog.fine("No mods found to sort"); + FMLLog.fine("No user mods found to sort"); } } @@ -336,6 +339,10 @@ public class Loader identifyDuplicates(mods); namedMods = Maps.uniqueIndex(mods, new ModIdFunction()); FMLLog.info("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size() != 1 ? "s" : ""); + for (String modId: namedMods.keySet()) + { + FMLLog.makeLog(modId); + } return discoverer; } @@ -436,6 +443,11 @@ public class Loader FMLLog.severe("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath); throw new LoaderException(); } + + loggingProperties = new File(canonicalConfigDir, "logging.properties"); + FMLLog.info("Reading custom logging properties from %s", loggingProperties.getPath()); + FMLRelaunchLog.loadLogConfiguration(loggingProperties); + FMLLog.log(Level.OFF,"Logging level for ForgeModLoader logging is set to %s", FMLRelaunchLog.log.getLogger().getLevel()); } public List getModList() @@ -457,6 +469,9 @@ public class Loader modController.transition(LoaderState.LOADING); ModDiscoverer disc = identifyMods(); disableRequestedMods(); + FMLLog.fine("Reloading logging properties from %s", loggingProperties.getPath()); + FMLRelaunchLog.loadLogConfiguration(loggingProperties); + FMLLog.fine("Reloaded logging properties"); modController.distributeStateMessage(FMLLoadEvent.class); sortModList(); mods = ImmutableList.copyOf(mods); @@ -477,11 +492,15 @@ public class Loader } modController.transition(LoaderState.CONSTRUCTING); modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable()); - FMLLog.fine("Mod signature data:"); + FMLLog.fine("Mod signature data"); for (ModContainer mod : getActiveModList()) { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), CertificateHelper.getFingerprint(mod.getSigningCertificate())); } + if (getActiveModList().isEmpty()) + { + FMLLog.fine("No user mod signature data found"); + } modController.transition(LoaderState.PREINITIALIZATION); modController.distributeStateMessage(LoaderState.PREINITIALIZATION, disc.getASMTable(), canonicalConfigDir); modController.transition(LoaderState.INITIALIZATION); @@ -490,22 +509,22 @@ public class Loader private void disableRequestedMods() { String forcedModList = System.getProperty("fml.modStates", ""); - FMLLog.fine("Received a system property request \'%s\'",forcedModList); + FMLLog.finer("Received a system property request \'%s\'",forcedModList); Map sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:")) .omitEmptyStrings().trimResults().withKeyValueSeparator("=") .split(forcedModList); - FMLLog.fine("System property request managing the state of %d mods", sysPropertyStateList.size()); + FMLLog.finer("System property request managing the state of %d mods", sysPropertyStateList.size()); Map modStates = Maps.newHashMap(); File forcedModFile = new File(canonicalConfigDir, "fmlModState.properties"); Properties forcedModListProperties = new Properties(); if (forcedModFile.exists() && forcedModFile.isFile()) { - FMLLog.fine("Found a mod state file %s", forcedModFile.getName()); + FMLLog.finer("Found a mod state file %s", forcedModFile.getName()); try { forcedModListProperties.load(new FileReader(forcedModFile)); - FMLLog.fine("Loaded states for %d mods from file", forcedModListProperties.size()); + FMLLog.finer("Loaded states for %d mods from file", forcedModListProperties.size()); } catch (Exception e) { @@ -762,7 +781,7 @@ public class Loader modController.transition(LoaderState.AVAILABLE); } - public boolean serverAboutToStart(MinecraftServer server) + public boolean serverAboutToStart(Object server) { try { diff --git a/fml/common/cpw/mods/fml/common/ModClassLoader.java b/fml/common/cpw/mods/fml/common/ModClassLoader.java index b5d8bf4ceb..2b69592ebd 100644 --- a/fml/common/cpw/mods/fml/common/ModClassLoader.java +++ b/fml/common/cpw/mods/fml/common/ModClassLoader.java @@ -70,7 +70,7 @@ public class ModClassLoader extends URLClassLoader } catch (URISyntaxException e) { - FMLLog.log(Level.SEVERE, "Unable to process our input to locate the minecraft code", e); + FMLLog.log(Level.SEVERE, e, "Unable to process our input to locate the minecraft code"); throw new LoaderException(e); } } diff --git a/fml/common/cpw/mods/fml/common/TickType.java b/fml/common/cpw/mods/fml/common/TickType.java index 30a00f8189..3e7426cd31 100644 --- a/fml/common/cpw/mods/fml/common/TickType.java +++ b/fml/common/cpw/mods/fml/common/TickType.java @@ -31,17 +31,14 @@ public enum TickType { */ RENDER, /** - * client side - * Fired during the render processing phase if a GUI is open - * arg 0 : float "partial render time" - * arg 1 : the open gui or null if no gui is open + * Not fired */ + @Deprecated GUI, /** - * client side - * Fired during the client evaluation loop - * arg 0 : The open gui or null if no gui is open + * Not fired */ + @Deprecated CLIENTGUI, /** * server side diff --git a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java index 411eb8a9a9..991d48e5f2 100644 --- a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java +++ b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java @@ -44,7 +44,7 @@ public class ModDiscoverer { if (knownLibraries.contains(minecraftSources[i].getName())) { - FMLLog.fine("Skipping known library file %s", minecraftSources[i].getAbsolutePath()); + FMLLog.finer("Skipping known library file %s", minecraftSources[i].getAbsolutePath()); } else { diff --git a/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java b/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java index a2d7e02f96..31f9f1131c 100644 --- a/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java +++ b/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java @@ -44,17 +44,23 @@ public class FMLInterModComms { * */ public static class IMCEvent extends FMLEvent { + private ModContainer activeContainer; + @Override public void applyModContainer(ModContainer activeContainer) { - currentList = ImmutableList.copyOf(modMessages.removeAll(activeContainer.getModId())); - FMLLog.finest("Attempting to deliver %d IMC messages to mod %s", currentList.size(), activeContainer.getModId()); + this.activeContainer = activeContainer; + FMLLog.finest("Attempting to deliver %d IMC messages to mod %s", modMessages.get(activeContainer.getModId()).size(), activeContainer.getModId()); } private ImmutableList currentList; public ImmutableList getMessages() { + if (currentList == null) + { + currentList = ImmutableList.copyOf(modMessages.removeAll(activeContainer.getModId())); + } return currentList; } } @@ -202,7 +208,7 @@ public class FMLInterModComms { ModContainer mc = FMLCommonHandler.instance().findContainerFor(forMod); if (mc != null) { - return ImmutableList.copyOf(modMessages.removeAll(mc)); + return ImmutableList.copyOf(modMessages.removeAll(mc.getModId())); } else { diff --git a/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java index 4bd09b866c..a0dbfab3ca 100644 --- a/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java +++ b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java @@ -81,6 +81,8 @@ public class FMLPreInitializationEvent extends FMLStateEvent /** * Get a logger instance configured to write to the FML Log as a parent, identified by modid. Handy for mod logging! + * Configurations can be applied through the config/logging.properties file, specifying logging levels + * for your ModID. Use this! * * @return A logger */ diff --git a/fml/common/cpw/mods/fml/common/registry/GameData.java b/fml/common/cpw/mods/fml/common/registry/GameData.java index 3929d37874..5514765225 100644 --- a/fml/common/cpw/mods/fml/common/registry/GameData.java +++ b/fml/common/cpw/mods/fml/common/registry/GameData.java @@ -50,13 +50,13 @@ public class GameData { ignoredMods = Maps.fromProperties(p); if (ignoredMods.size()>0) { - FMLLog.warning("Using non-empty ignored mods configuration file %s", ignoredMods.keySet()); + FMLLog.log("fml.ItemTracker", Level.WARNING, "Using non-empty ignored mods configuration file %s", ignoredMods.keySet()); } } catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(Level.SEVERE, e, "Failed to read ignored ID checker mods properties file"); + FMLLog.log("fml.ItemTracker", Level.SEVERE, e, "Failed to read ignored ID checker mods properties file"); ignoredMods = ImmutableMap.of(); } } @@ -84,12 +84,12 @@ public class GameData { if (idMap.containsKey(item.field_77779_bT)) { ItemData id = idMap.get(item.field_77779_bT); - FMLLog.info("[ItemTracker] The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); + FMLLog.log("fml.ItemTracker", Level.INFO, "The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); } idMap.put(item.field_77779_bT, itemData); if (!"Minecraft".equals(mc.getModId())) { - FMLLog.fine("[ItemTracker] Adding item %s(%d) owned by %s", item.getClass().getName(), item.field_77779_bT, mc.getModId()); + FMLLog.log("fml.ItemTracker",Level.FINE, "Adding item %s(%d) owned by %s", item.getClass().getName(), item.field_77779_bT, mc.getModId()); } } @@ -119,12 +119,12 @@ public class GameData { Map worldMap = Maps.uniqueIndex(worldSaveItems,idMapFunction); difference = Maps.difference(worldMap, idMap); - FMLLog.fine("The difference set is %s", difference); + FMLLog.log("fml.ItemTracker", Level.FINE, "The difference set is %s", difference); if (!difference.entriesDiffering().isEmpty() || !difference.entriesOnlyOnLeft().isEmpty()) { - FMLLog.severe("FML has detected item discrepancies"); - FMLLog.severe("Missing items : %s", difference.entriesOnlyOnLeft()); - FMLLog.severe("Mismatched items : %s", difference.entriesDiffering()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "FML has detected item discrepancies"); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "Missing items : %s", difference.entriesOnlyOnLeft()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "Mismatched items : %s", difference.entriesDiffering()); boolean foundNonIgnored = false; for (ItemData diff : difference.entriesOnlyOnLeft().values()) { @@ -142,7 +142,7 @@ public class GameData { } if (!foundNonIgnored) { - FMLLog.severe("FML is ignoring these ID discrepancies because of configuration. YOUR GAME WILL NOW PROBABLY CRASH. HOPEFULLY YOU WON'T HAVE CORRUPTED YOUR WORLD. BLAME %s", ignoredMods.keySet()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "FML is ignoring these ID discrepancies because of configuration. YOUR GAME WILL NOW PROBABLY CRASH. HOPEFULLY YOU WON'T HAVE CORRUPTED YOUR WORLD. BLAME %s", ignoredMods.keySet()); } isSaveValid = !foundNonIgnored; serverValidationLatch.countDown(); diff --git a/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java b/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java index 0eda645693..34ce2220e6 100644 --- a/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java +++ b/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java @@ -7,6 +7,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; import com.google.common.base.Charsets; @@ -141,8 +142,7 @@ public class LanguageRegistry addStringLocalization(langPack, lang); } catch (IOException e) { - FMLLog.getLogger().severe("Unable to load localization from file: " + localizationFile); - e.printStackTrace(); + FMLLog.log(Level.SEVERE, e, "Unable to load localization from file %s", localizationFile); } finally { try { @@ -151,7 +151,7 @@ public class LanguageRegistry } } catch (IOException ex) { - ex.printStackTrace(); + // HUSH } } } diff --git a/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java b/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java index 17529820fc..88d85830cf 100644 --- a/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java +++ b/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java @@ -2,6 +2,8 @@ package cpw.mods.fml.relauncher; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.Executors; @@ -112,7 +114,7 @@ public class FMLRelaunchLog } /** * Our special logger for logging issues to. We copy various assets from the - * Minecraft logger to acheive a similar appearance. + * Minecraft logger to achieve a similar appearance. */ public static FMLRelaunchLog log = new FMLRelaunchLog(); @@ -124,6 +126,10 @@ public class FMLRelaunchLog private static PrintStream errCache; private Logger myLog; + private static FileHandler fileHandler; + + private static FMLLogFormatter formatter; + private FMLRelaunchLog() { } @@ -142,37 +148,66 @@ public class FMLRelaunchLog stdOut.setParent(log.myLog); Logger stdErr = Logger.getLogger("STDERR"); stdErr.setParent(log.myLog); - FMLLogFormatter formatter = new FMLLogFormatter(); - - // Console handler captures the normal stderr before it gets replaced + log.myLog.setLevel(Level.ALL); log.myLog.setUseParentHandlers(false); - log.myLog.addHandler(new ConsoleLogWrapper()); consoleLogThread = new Thread(new ConsoleLogThread()); consoleLogThread.start(); - ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO"))); - ConsoleLogThread.wrappedHandler.setFormatter(formatter); - log.myLog.setLevel(Level.ALL); + formatter = new FMLLogFormatter(); try { File logPath = new File(minecraftHome, FMLRelauncher.logFileNamePattern); - FileHandler fileHandler = new FileHandler(logPath.getPath(), 0, 3); - fileHandler.setFormatter(formatter); - fileHandler.setLevel(Level.ALL); - log.myLog.addHandler(fileHandler); + fileHandler = new FileHandler(logPath.getPath(), 0, 3) + { + public synchronized void close() throws SecurityException { + // We don't want this handler to reset + } + }; } catch (Exception e) { } + resetLoggingHandlers(); + // Set system out to a log stream errCache = System.err; System.setOut(new PrintStream(new LoggingOutStream(stdOut), true)); System.setErr(new PrintStream(new LoggingOutStream(stdErr), true)); - // Reset global logging to shut up other logging sources (thanks guava!) configured = true; } + private static void resetLoggingHandlers() + { + ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO"))); + // Console handler captures the normal stderr before it gets replaced + log.myLog.addHandler(new ConsoleLogWrapper()); + ConsoleLogThread.wrappedHandler.setFormatter(formatter); + fileHandler.setLevel(Level.ALL); + fileHandler.setFormatter(formatter); + log.myLog.addHandler(fileHandler); + } + + public static void loadLogConfiguration(File logConfigFile) + { + if (logConfigFile!=null && logConfigFile.exists() && logConfigFile.canRead()) + { + try + { + LogManager.getLogManager().readConfiguration(new FileInputStream(logConfigFile)); + resetLoggingHandlers(); + } + catch (Exception e) + { + log(Level.SEVERE, e, "Error reading logging configuration file %s", logConfigFile.getName()); + } + } + } + public static void log(String logChannel, Level level, String format, Object... data) + { + makeLog(logChannel); + Logger.getLogger(logChannel).log(level, String.format(format, data)); + } public static void log(Level level, String format, Object... data) { @@ -183,6 +218,12 @@ public class FMLRelaunchLog log.myLog.log(level, String.format(format, data)); } + public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) + { + makeLog(logChannel); + Logger.getLogger(logChannel).log(level, String.format(format, data), ex); + } + public static void log(Level level, Throwable ex, String format, Object... data) { if (!configured) @@ -225,4 +266,9 @@ public class FMLRelaunchLog { return myLog; } + public static void makeLog(String logChannel) + { + Logger l = Logger.getLogger(logChannel); + l.setParent(log.myLog); + } } diff --git a/fml/install/fml.py b/fml/install/fml.py index be3d225bb5..766c46082f 100644 --- a/fml/install/fml.py +++ b/fml/install/fml.py @@ -223,7 +223,9 @@ def cleanup_source(path): src_file = os.path.normpath(os.path.join(path, cur_file)) updatefile(src_file) -def setup_fml(fml_dir, mcp_dir): +compile_tools = True +def setup_fml(fml_dir, mcp_dir, disable_at=False, disable_merge=False, enable_server=False, disable_client=False): + global compile_tools sys.path.append(mcp_dir) from runtime.decompile import decompile from runtime.cleanup import cleanup @@ -245,7 +247,10 @@ def setup_fml(fml_dir, mcp_dir): if not download_deps(mcp_dir): sys.exit(1) + compile_tools = True + def applyrg_shunt(self, side, reobf=False, applyrg_real = Commands.applyrg): + global compile_tools if not self.has_wine and not self.has_astyle: self.logger.error('!! Please install either wine or astyle for source cleanup !!') self.logger.error('!! This is REQUIRED by FML/Forge Cannot proceed !!') @@ -262,7 +267,7 @@ def setup_fml(fml_dir, mcp_dir): cmd_compile = '"%s" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "{classpath}" -sourcepath "{sourcepath}" -d "{outpath}" "{target}"' % self.cmdjavac cmd_compile = cmd_compile.format(classpath=class_path, sourcepath=dir_common, outpath=dir_bin, target="{target}") - if (side == CLIENT): + if compile_tools: self.logger.info('> Compiling AccessTransformer') if not runcmd(self, cmd_compile.format(target=os.path.join(dir_trans, 'AccessTransformer.java')), echo=False): sys.exit(1) @@ -270,32 +275,41 @@ def setup_fml(fml_dir, mcp_dir): self.logger.info('> Compiling MCPMerger') if not runcmd(self, cmd_compile.format(target=os.path.join(dir_trans, 'MCPMerger.java')), echo=False): sys.exit(1) - - self.logger.info('> Running MCPMerger') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.MCPMerger "{mergecfg}" "{client}" "{server}"' % self.cmdjava).format( - classpath=class_path, mergecfg=os.path.join(fml_dir, 'mcp_merge.cfg'), client=jars[CLIENT], server=jars[SERVER]) + compile_tools = False + + if side == CLIENT: + if not disable_merge: + self.logger.info('> Running MCPMerger') + forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.MCPMerger "{mergecfg}" "{client}" "{server}"' % self.cmdjava).format( + classpath=class_path, mergecfg=os.path.join(fml_dir, 'mcp_merge.cfg'), client=jars[CLIENT], server=jars[SERVER]) + + if not runcmd(self, forkcmd): + sys.exit(1) + else: + self.logger.info('> MCPMerge disabled') + + if not disable_at: + self.logger.info('> Running AccessTransformer') + forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.AccessTransformer "{jar}" "{fmlconfig}"' % self.cmdjava).format( + classpath=class_path, jar=jars[side], fmlconfig=os.path.join(fml_dir, 'common', 'fml_at.cfg')) + + forge_cfg = os.path.join(fml_dir, '..', 'common', 'forge_at.cfg') + if os.path.isfile(forge_cfg): + self.logger.info(' Forge config detected') + forkcmd += ' "%s"' % forge_cfg + + for dirname, dirnames, filenames in os.walk(os.path.join(fml_dir, '..', 'accesstransformers')): + for filename in filenames: + accesstransformer = os.path.join(dirname, filename) + if os.path.isfile(accesstransformer): + self.logger.info(' Access Transformer "%s" detected' % filename) + forkcmd += ' "%s"' % accesstransformer + if not runcmd(self, forkcmd): sys.exit(1) - - self.logger.info('> Running AccessTransformer') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.AccessTransformer "{jar}" "{fmlconfig}"' % self.cmdjava).format( - classpath=class_path, jar=jars[side], fmlconfig=os.path.join(fml_dir, 'common', 'fml_at.cfg')) - - forge_cfg = os.path.join(fml_dir, '..', 'common', 'forge_at.cfg') - if os.path.isfile(forge_cfg): - self.logger.info(' Forge config detected') - forkcmd += ' "%s"' % forge_cfg - - for dirname, dirnames, filenames in os.walk(os.path.join(fml_dir, '..', 'accesstransformers')): - for filename in filenames: - accesstransformer = os.path.join(dirname, filename) - if os.path.isfile(accesstransformer): - self.logger.info(' Access Transformer "%s" detected' % filename) - forkcmd += ' "%s"' % accesstransformer - - if not runcmd(self, forkcmd): - sys.exit(1) + else: + self.logger.info('> Access Transformer disabled') self.logger.info('> Really Applying Retroguard') applyrg_real(self, side, reobf) @@ -318,8 +332,8 @@ def setup_fml(fml_dir, mcp_dir): Commands.applyrg = applyrg_shunt Commands.checkjars = checkjars_shunt #decompile -d -n -r - # Conf JAD CSV -r -d -a -n -p -o -l -g -c -s - decompile(None, False, False, True, True, False, True, False, False, False, False, True, False) + # Conf JAD CSV -r -d -a -n -p -o -l -g -c -s + decompile(None, False, False, True, True, False, True, False, False, False, False, not disable_client, enable_server) reset_logger() os.chdir(fml_dir) @@ -338,8 +352,14 @@ def setup_fml(fml_dir, mcp_dir): os.chdir(mcp_dir) commands = Commands(verify=True) - updatemd5_side(mcp_dir, commands, CLIENT) - reset_logger() + + if not disable_client: + updatemd5_side(mcp_dir, commands, CLIENT) + reset_logger() + + if enable_server: + updatemd5_side(mcp_dir, commands, CLIENT) + reset_logger() os.chdir(fml_dir) @@ -413,16 +433,16 @@ def apply_fml_patches(fml_dir, mcp_dir, src_dir, copy_files=True): if os.path.isdir(os.path.join(src_dir, 'minecraft', 'argo')): shutil.rmtree(os.path.join(src_dir, 'minecraft', 'argo')) -def finish_setup_fml(fml_dir, mcp_dir): +def finish_setup_fml(fml_dir, mcp_dir, enable_server=False, disable_client=False): sys.path.append(mcp_dir) from runtime.updatenames import updatenames from runtime.updatemd5 import updatemd5 from runtime.updatemcp import updatemcp os.chdir(mcp_dir) - updatenames(None, True, True, False) + updatenames(None, True, not disable_client, enable_server) reset_logger() - updatemd5(None, True, True, False) + updatemd5(None, True, not disable_client, enable_server) reset_logger() os.chdir(fml_dir) @@ -944,18 +964,21 @@ def gen_renamed_conf(mcp_dir, fml_dir): cls = repackage_class(pkgs, cls) outf.write('%s.%s%s=%s\n' % (cls, func, sig, named)) - print 'Creating re-packaged MCP patch' - patch_in = os.path.join(mcp_dir, 'conf', 'patches', 'minecraft_ff.patch') - patch_tmp = os.path.join(mcp_dir, 'conf', 'patches', 'minecraft_ff.patch.tmp') + print 'Creating re-packaged MCP patches' - regnms = re.compile(r'net\\minecraft\\src\\(\w+)') - with open(patch_in, 'r') as fh: - buf = fh.read() - def mapname(match): - return repackage_class(pkgs, match.group(0).replace('\\', '/')).replace('/', '\\') - buf = regnms.sub(mapname, buf) - - with open(patch_tmp, 'w') as fh: - fh.write(buf) - - shutil.move(patch_tmp, patch_in) + def fix_patches(patch_in, patch_tmp): + regnms = re.compile(r'net\\minecraft\\src\\(\w+)') + with open(patch_in, 'r') as fh: + buf = fh.read() + def mapname(match): + return repackage_class(pkgs, match.group(0).replace('\\', '/')).replace('/', '\\') + buf = regnms.sub(mapname, buf) + + with open(patch_tmp, 'w') as fh: + fh.write(buf) + + shutil.move(patch_tmp, patch_in) + + patch_dir = os.path.join(mcp_dir, 'conf', 'patches') + fix_patches(os.path.join(patch_dir, 'minecraft_ff.patch' ), os.path.join(patch_dir, 'tmp.patch')) + fix_patches(os.path.join(patch_dir, 'minecraft_server_ff.patch'), os.path.join(patch_dir, 'tmp.patch')) diff --git a/fml/install/install.bat b/fml/install/install.bat index 4698e2b229..b31f477296 100644 --- a/fml/install/install.bat +++ b/fml/install/install.bat @@ -1,4 +1,4 @@ echo off @set PATH=%PATH%;%SystemDir%\system32;%SystemRoot%\System32;.\python\ -python_fml install.py +python_fml install.py %* pause diff --git a/fml/install/install.py b/fml/install/install.py index 5971c78af0..97dec17703 100644 --- a/fml/install/install.py +++ b/fml/install/install.py @@ -3,24 +3,41 @@ from optparse import OptionParser from fml import setup_fml, finish_setup_fml, apply_fml_patches, setup_mcp -def fml_main(fml_dir, mcp_dir, dont_gen_conf=True): +def fml_main(fml_dir, mcp_dir, dont_gen_conf=True, disable_patches=False, disable_at=False, disable_merge=False, enable_server=False, disable_client=False): print '================ Forge ModLoader Setup Start ===================' setup_mcp(fml_dir, mcp_dir, dont_gen_conf) - setup_fml(fml_dir, mcp_dir) - apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src')) - finish_setup_fml(fml_dir, mcp_dir) + setup_fml(fml_dir, mcp_dir, disable_at=disable_at, disable_merge=disable_merge, enable_server=enable_server, disable_client=disable_client) + if disable_patches: + print 'Patching disabled' + else: + apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src')) + finish_setup_fml(fml_dir, mcp_dir, enable_server=enable_server, disable_client=disable_client) print '================ Forge ModLoader Setup End ===================' if __name__ == '__main__': parser = OptionParser() - parser.add_option('-m', '--mcp-dir', action='store_true', dest='mcp_dir', help='Path to download/extract MCP to', default=None) + parser.add_option('-m', '--mcp-dir', action='store_true', dest='mcp_dir', help='Path to download/extract MCP to', default=None ) + parser.add_option('-p', '--no-patch', action="store_true", dest='no_patch', help='Disable application of FML patches', default=False) + parser.add_option('-a', '--no-access', action="store_true", dest='no_access', help='Disable access transformers', default=False) + parser.add_option('-s', '--server', action="store_true", dest='enable_server', help='Enable decompilation of server', default=False) + parser.add_option('-c', '--no-client', action="store_true", dest='no_client', help='Disable decompilation of server', default=False) + parser.add_option('-e', '--no-merge', action="store_true", dest='no_merge', help='Disable merging server code into client', default=False) options, _ = parser.parse_args() fml_dir = os.path.dirname(os.path.abspath(__file__)) + mcp_dir = os.path.abspath('mcp') if not options.mcp_dir is None: - fml_main(fml_dir, os.path.abspath(options.mcp_dir)) + mcp_dir = os.path.abspath(options.mcp_dir) elif os.path.isfile(os.path.join('..', 'runtime', 'commands.py')): - fml_main(fml_dir, os.path.abspath('..')) - else: - fml_main(fml_dir, os.path.abspath('mcp')) \ No newline at end of file + mcp_dir = os.path.abspath('..') + + if options.no_client: + options.no_patch = True + + if options.no_merge: + options.no_patch = True + + fml_main(fml_dir, mcp_dir, disable_patches=options.no_patch, + disable_at=options.no_access, disable_merge=options.no_merge, + enable_server=options.enable_server, disable_client=options.no_client) \ No newline at end of file