package com.mcmoddev.nethermetals.init;

import java.util.Arrays;
import java.util.List;

import com.mcmoddev.lib.block.BlockMMDNetherOre;
import com.mcmoddev.lib.data.Names;
import com.mcmoddev.lib.data.SharedStrings;
import com.mcmoddev.lib.init.Materials;
import com.mcmoddev.lib.material.MMDMaterial;
import com.mcmoddev.lib.util.Oredicts;

import net.minecraft.block.Block;

/**
 * This class initializes all blocks in Nether Metals.
 *
 * @author Jasmine Iwanek
 *
 */
public final class NetherBlocks extends com.mcmoddev.lib.init.Blocks {

	/**
	 *
	 */
	public static void init() {
		final List<String> knownMaterials = Arrays.asList("coal", "diamond", "emerald", "gold",
				"iron", "lapis", "redstone", "antimony", "bismuth", "copper", "lead", "mercury",
				"nickel", "platinum", "silver", "tin", "zinc", "aluminum", "cadmium", "chromium",
				"iridium", "magnesium", "manganese", "osmium", "plutonium", "rutile", "tantalum",
				"titanium", "tungsten", "uranium", "zirconium");
		Materials.getAllMaterials().stream().map(material -> material.getName())
				.filter(knownMaterials::contains).filter(Materials::hasMaterial)
				.forEach(NetherBlocks::createOreWrapper);
	}

	private static void createOreWrapper(final String materialName) {
		final List<String> vanillaMats = Arrays.asList("coal", "diamond", "emerald", "gold", "iron",
				"lapis", "redstone");

		if (vanillaMats.contains(materialName)) {
			createVanillaOreWrapper(materialName);
		} else {
			create(Names.NETHERORE, materialName);
		}
	}

	private static void createVanillaOreWrapper(final String materialName) {
		final MMDMaterial material = Materials.getMaterialByName(materialName);
		material.addNewBlock(Names.NETHERORE, addBlock(new BlockMMDNetherOre(material),
				Names.NETHERORE.toString(), material, ItemGroups.getTab(SharedStrings.TAB_BLOCKS)));
		final Block block = material.getBlock(Names.NETHERORE);
		final String oredict = getOredictFromName(Names.NETHERORE);
		if ((oredict != null) && (block != null)) {
			Oredicts.registerOre(oredict + material.getCapitalizedName(), block);
		}
	}
}

@@ -336,16 +336,63 @@
 redicts;
+%0Aimport com.mcmoddev.nethermetals.NetherMetals;
 %0A%0Aimport
@@ -1030,16 +1030,19 @@
 nium%22);%0A
+%09%09%0A
 %09%09Materi
@@ -1071,16 +1071,52 @@
 stream()
+.filter(MMDMaterial::isVanilla)%0A%09%09%09%09
 .map(mat
@@ -1142,24 +1142,223 @@
 etName())%0A%09%09
+%09%09.filter(knownMaterials::contains)%0A%09%09%09%09.forEach(NetherBlocks::createVanillaOreWrapper);%0A%09%09Materials.getAllMaterials().stream().filter(mat -%3E !mat.isVanilla())%0A%09%09.map(material -%3E material.getName())%0A
 %09%09.filter(kn
@@ -1412,18 +1412,16 @@
 terial)%0A
-%09%09
 %09%09.forEa
@@ -1648,17 +1648,83 @@
 tone%22);%0A
+%09%09NetherMetals.LOGGER.fatal(%22createOreWrapper(%25s)%22, materialName);
 %0A
-
 %09%09if (va
@@ -1858,24 +1858,24 @@
 e);%0A%09%09%7D%0A%09%7D%0A%0A
-
 %09private sta
@@ -1928,32 +1928,106 @@
 materialName) %7B%0A
+%09%09NetherMetals.LOGGER.fatal(%22createVanillaOreWrapper(%25s)%22, materialName);%0A
 %09%09final MMDMater

fix an issue caused by the former tight coupling of MMDLib and BaseMetals