package mnm.mods.util;

import java.util.Iterator;
import java.util.List;

import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;

public class TweakTools {

    /**
     * Returns whether LiteLoader is loaded into LaunchWrapper.
     *
     * @return True if it's loaded
     */
    public static boolean isLiteLoaderLoaded() {
        return isTweakLoaded("com.mumfrey.liteloader.launch.LiteLoaderTweaker");
    }

    /**
     * Returns whether FML is loaded into LaunchWrapper.
     *
     * @return True if it's loaded
     */
    public static boolean isFMLLoaded() {
        return isTweakLoaded("net.minecraftforge.fml.common.launcher.FMLTweaker");
    }

    /**
     * Gets if a given tweak is loaded into LaunchWrapper.
     *
     * @param name The fully qualified class name
     * @return True if it's loaded
     */
    public static boolean isTweakLoaded(String name) {
        boolean load = false;
        @SuppressWarnings("unchecked")
        List<ITweaker> tweakers = (List<ITweaker>) Launch.blackboard.get("Tweaks");

        // Iterate through the tweaks and check the class name
        Iterator<ITweaker> iter = tweakers.iterator();
        while (!load && iter.hasNext()) {
            ITweaker tweak = iter.next();
            String className = tweak.getClass().getName();
            load = className.equals(name);
        }
        return load;
    }
}

@@ -28,138 +28,102 @@
 ort 
-java.util.Iterator;%0Aimport java.util.List;%0A%0Aimport net.minecraft.launchwrapper.ITweak
+net.minecraftforge.fml.common.FMLCommonHandl
 er;%0A
+%0A
 import 
-net.minecraft.launchwrapper.Launch
+com.mumfrey.liteloader.core.LiteLoader
 ;%0A%0Ap
@@ -197,33 +197,24 @@
  is 
-loaded into LaunchWrapper
+currently loaded
 .%0A  
@@ -322,326 +322,164 @@
     
-return isTweakLoaded(%22com.mumfrey.liteloader.launch.LiteLoaderTweaker%22)
+boolean loaded = false
 ;%0A    
-%7D%0A%0A
     
-/**
+try %7B
 %0A     
-* Returns whether FML is loaded into LaunchWrapper.%0A     *%0A     * @return True if it's loaded%0A     */%0A    public static boolean isFMLLoaded() %7B%0A        return isTweakLoaded(%22net.minecraftforge.fml.common.launcher.FMLTweaker%22)
+       loaded = LiteLoader.getInstance() != null;%0A        %7D catch (Throwable t) %7B%0A        %7D%0A        return loaded
 ;%0A  
@@ -502,116 +502,55 @@
   * 
-Gets if a given tweak is loaded into LaunchWrapper.%0A     *%0A     * @param name The fully qualified class name
+Returns whether FML is currently loaded.%0A     *
 %0A   
@@ -621,31 +621,18 @@
 n is
-Tweak
+FML
 Loaded(
-String name
 ) %7B%0A
@@ -651,16 +651,18 @@
 ean load
+ed
  = false
@@ -675,426 +675,96 @@
     
-@SuppressWarnings(%22unchecked%22)%0A        List%3CITweaker%3E tweakers = (List%3CITweaker%3E) Launch.blackboard.get(%22Tweaks%22);%0A%0A        // Iterate through the tweaks and check the class name%0A        Iterator%3CITweaker%3E iter = tweakers.iterator();%0A        while (!load && iter.hasNext()) %7B%0A            ITweaker tweak = iter.next();%0A            String className = tweak.getClass().getName();%0A            load = className.equals(name)
+if (ForgeUtils.FML_INSTALLED) %7B%0A            loaded = FMLCommonHandler.instance() != null
 ;%0A  
@@ -790,16 +790,18 @@
 urn load
+ed
 ;%0A    %7D%0A

Make the tweak tools actually useful. Fix always returning false because the Tweaks list is empty.