package com.teamacronymcoders.contenttweaker;

import com.teamacronymcoders.base.BaseModFoundation;
import com.teamacronymcoders.base.util.files.BaseFileUtils;
import com.teamacronymcoders.contenttweaker.api.ContentTweakerAPI;
import com.teamacronymcoders.contenttweaker.proxies.CommonProxy;
import crafttweaker.runtime.CrTTweaker;
import crafttweaker.runtime.ITweaker;
import crafttweaker.runtime.providers.ScriptProviderDirectory;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import java.io.File;

import static com.teamacronymcoders.contenttweaker.ContentTweaker.*;

@Mod(modid = MOD_ID, name = MOD_NAME, version = VERSION, dependencies = DEPENDS)
public class ContentTweaker extends BaseModFoundation<ContentTweaker> {
    public static final String MOD_ID = "contenttweaker";
    public static final String MOD_NAME = "ContentTweaker";
    public static final String VERSION = "@VERSION@";
    public static final String DEPENDS = "required-after:base@[0.0.0,);required-after:crafttweaker;";

    private ITweaker scriptHandler = new CrTTweaker();

    @Instance(MOD_ID)
    public static ContentTweaker instance;

    @SidedProxy(clientSide = "com.teamacronymcoders.contenttweaker.proxies.ClientProxy",
            serverSide = "com.teamacronymcoders.contenttweaker.proxies.ServerProxy")
    public static CommonProxy proxy;

    public ContentTweaker() {
        super(MOD_ID, MOD_NAME, VERSION, null, true);
        ContentTweakerAPI.setInstance(new ContentTweakerAPI(new ModWrapper()));
    }

    @EventHandler
    @Override
    public void preInit(FMLPreInitializationEvent event) {
        super.preInit(event);
        proxy.createErrorSilencingLoader();
    }

    @Override
    public void afterModuleHandlerInit(FMLPreInitializationEvent event) {
        File resourceFolder = this.getResourceFolder();
        if (resourceFolder != null && resourceFolder.isDirectory()) {
            File minecraftFolder = resourceFolder.getParentFile();
            File contentTweakerScripts = new File(minecraftFolder, "scripts-contenttweaker");
            BaseFileUtils.createFolder(contentTweakerScripts);
            scriptHandler.setScriptProvider(new ScriptProviderDirectory(contentTweakerScripts));
            scriptHandler.load();
        } else {
            this.getLogger().fatal("Couldn't create folder for scripts");
        }
    }

    @EventHandler
    @Override
    public void init(FMLInitializationEvent event) {
        super.init(event);
    }

    @EventHandler
    @Override
    public void postInit(FMLPostInitializationEvent event) {
        super.postInit(event);
    }

    @Override
    public boolean addOBJDomain() {
        return true;
    }

    @Override
    public boolean hasExternalResources() {
        return true;
    }

    @Override
    public ContentTweaker getInstance() {
        return this;
    }
}

@@ -2121,205 +2121,8 @@
 ) %7B%0A
-        File resourceFolder = this.getResourceFolder();%0A        if (resourceFolder != null && resourceFolder.isDirectory()) %7B%0A            File minecraftFolder = resourceFolder.getParentFile();%0A    
     
@@ -2163,17 +2163,25 @@
 ew File(
-m
+this.getM
 inecraft
@@ -2186,16 +2186,18 @@
 ftFolder
+()
 , %22scrip
@@ -2225,20 +2225,16 @@
         
-   
- 
 BaseFile
@@ -2276,20 +2276,16 @@
 ripts);%0A
-    
         
@@ -2373,28 +2373,24 @@
 ));%0A        
-    
 scriptHandle
@@ -2403,109 +2403,8 @@
 ();%0A
-        %7D else %7B%0A            this.getLogger().fatal(%22Couldn't create folder for scripts%22);%0A        %7D%0A
     

Make use of new MC folder