package nallar.tickprofiler.minecraft;

import me.nallar.modpatcher.ModPatcher;
import nallar.tickprofiler.Log;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;

import java.util.*;


@IFMLLoadingPlugin.MCVersion("@MC_VERSION@")
@IFMLLoadingPlugin.SortingIndex(1001)
public class CoreMod implements IFMLLoadingPlugin {
	static {
		ModPatcher.requireVersion("1.10.2.1");
	}

	@Override
	public String[] getASMTransformerClass() {
		return new String[0];
	}

	@Override
	public String getModContainerClass() {
		return null;
	}

	@Override
	public String getSetupClass() {
		return ModPatcher.getSetupClass();
	}

	private Boolean spongePresent;

	private boolean isSpongePresent() {
		if (spongePresent == null) {
			try {
				Class.forName("org.spongepowered.asm.mixin.MixinEnvironment", false, CoreMod.class.getClassLoader());
				spongePresent = true;
			} catch (ClassNotFoundException e) {
				spongePresent = false;
			}
		}

		return spongePresent;
	}

	@Override
	public void injectData(Map<String, Object> data) {
		Log.info("TickProfiler v@MOD_VERSION@ coremod loading. Sponge present: " + isSpongePresent());

		ModPatcher.loadPatches(CoreMod.class.getResourceAsStream("/entityhook.xml"));
		// TODO: Not implemented
		// ModPatcher.loadPatches(CoreMod.class.getResourceAsStream("/packethook.xml"));
	}

	@Override
	public String getAccessTransformerClass() {
		return null;
	}
}

@@ -369,17 +369,17 @@
 %221.10.2.
-1
+8
 %22);%0A%09%7D%0A%0A

Fix #55 (require ModPatcher 1.10.2.8)