package net.shadowfacts.enfusion.compat;

import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.shadowfacts.enfusion.EnFusion;
import net.shadowfacts.enfusion.item.EFItems;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * ExNihilo Compatibility
 * @author shadowfacts
 */
public class CompatExNihilo {
	public static void preInit() {

	}

	public static void init() {
		// Add Zinchorium Dust to ExNihilo Sieve Registry for Dust
		try {
			Class sieveRegistry = Class.forName("exnihilo.registries.SieveRegistry");

			// void register(Block source, Item output, int outputMeta, int rarity)
			Method register = sieveRegistry.getMethod("register", Block.class, Item.class, int.class, int.class);

			Block blockDust = GameRegistry.findBlock("exnihilo", "dust");

			if (blockDust != null) {

				register.invoke(null, blockDust, EFItems.zinchoriumDust, 0, 10);

			} else {
				EnFusion.log.error("Umm, dust should be a block, right?");
				return;
			}

		} catch (ClassNotFoundException e) {
			EnFusion.log.error("There was a problem loading the ExNihilo classes, uh oh.");
			EnFusion.log.error("Report this immediately at: http://github.com/shadowfacts/EnFusion/issues");
			EnFusion.log.error(e.getMessage());
		} catch (NoSuchMethodException e) {
			EnFusion.log.error("There was a problem loading a method from one of the ExNihilo classes, uh oh.");
			EnFusion.log.error("Report this immediately at: http://github.com/shadowfacts/EnFusion/issues");
			EnFusion.log.error(e.getMessage());
		} catch (IllegalAccessException e) {
			EnFusion.log.error("There was a problem accessing a method from one of the ExNihilo classes (IllegalAccessException), uh oh.");
			EnFusion.log.error("Report this immediately at: http://github.com/shadowfacts/EnFusion/issues");
			EnFusion.log.error(e.getMessage());
		} catch (InvocationTargetException e) {
			EnFusion.log.error("There was a problem accessing a method from one of the ExNihilo classes (InvocationTargetException), uh oh.");
			EnFusion.log.error("Report this immediately at: http://github.com/shadowfacts/EnFusion/issues");
			EnFusion.log.error(e.getMessage());
		}
	}

	public static void postInit() {

	}
}

@@ -119,16 +119,50 @@
 .Block;%0A
+import net.minecraft.init.Blocks;%0A
 import n
@@ -753,16 +753,22 @@
 register
+Method
  = sieve
@@ -847,16 +847,26 @@
 lass);%0A%0A
+//%09%09%09Dust%0A
 %09%09%09Block
@@ -922,17 +922,16 @@
 dust%22);%0A
-%0A
 %09%09%09if (b
@@ -963,16 +963,22 @@
 register
+Method
 .invoke(
@@ -1020,16 +1020,87 @@
 Dust, 0,
+ 5);%0A%09%09%09%09registerMethod.invoke(null, blockDust, EFItems.dustPeridot, 0,
  10);%0A%0A%09
@@ -1191,16 +1191,104 @@
 ;%0A%09%09%09%7D%0A%0A
+//%09%09%09Gravel%0A%09%09%09registerMethod.invoke(null, Blocks.gravel, EFItems.gemPeridot, 0, 10);%0A%0A%0A
 %09%09%7D catc

Add Peridot Ex Nihilo Compatibility