package ljfa.glassshards.compat;

import ljfa.glassshards.Config;
import ljfa.glassshards.Reference;
import ljfa.glassshards.api.GlassType;
import ljfa.glassshards.util.LogHelper;
import net.minecraft.block.Block;

import org.apache.logging.log4j.Level;

import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;

public class ModGlassHelper {
    public static ChiselGlassHelper chiselHelper = null;
    public static TinkersGlassHelper tinkersHelper = null;
    
    public static void postInit() {
        if(Config.chiselEnable && Loader.isModLoaded("chisel")) {
            try {
                chiselHelper = new ChiselGlassHelper();
                LogHelper.info("Successfully loaded Chisel compatibility.");
            } catch(Exception ex) {
                FMLLog.log(Reference.MODNAME, Level.ERROR, ex, "Failed to load Chisel compatibility.");
            }
        }
        
        if(Loader.isModLoaded("TConstruct")) {
            try {
                tinkersHelper = new TinkersGlassHelper();
                LogHelper.info("Successfully loaded Tinkers Construct compatibility.");
            } catch(Exception ex) {
                FMLLog.log(Reference.MODNAME, Level.ERROR, ex, "Failed to load Tinkers Construct compatibility.");
            }
        }
    }

    public static boolean shouldRemoveDrop(Block block, int meta) {
        return Config.chiselFixPaneDrops && chiselHelper != null && chiselHelper.shouldRemoveDrop(block, meta)
                || tinkersHelper != null && tinkersHelper.shouldRemoveDrop(block, meta);
    }
    
    public static GlassType getType(Block block, int meta) {
        if(chiselHelper != null)
            return chiselHelper.getType(block, meta);
        else if(tinkersHelper != null)
            return tinkersHelper.getType(block, meta);
        else
            return null;
    }
}

@@ -1621,32 +1621,57 @@
 ck, int meta) %7B%0A
+        GlassType gtype;%0A
         if(chise
@@ -1678,32 +1678,34 @@
 lHelper != null)
+ %7B
 %0A            ret
@@ -1701,22 +1701,23 @@
         
-return
+gtype =
  chiselH
@@ -1752,20 +1752,85 @@
         
-else
+    if(gtype != null)%0A                return gtype;%0A        %7D%0A       
  if(tink
@@ -1839,32 +1839,34 @@
 sHelper != null)
+ %7B
 %0A            ret
@@ -1862,22 +1862,23 @@
         
-return
+gtype =
  tinkers
@@ -1918,17 +1918,70 @@
     
-else%0A    
+    if(gtype != null)%0A                return gtype;%0A        %7D%0A
     

Fix logic derp