diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index 1c4a7356f..613fd26d6 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -54,6 +54,8 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import rebelkeithy.mods.metallurgy.api.*; + /** * Mekanism - the mod in which no true definition fits. * @author AidanBrady @@ -978,8 +980,60 @@ public class Mekanism RecipeHandler.addCombinerRecipe(MekanismUtils.getStackWithSize(ore, 8), MekanismUtils.getStackWithSize(OreDictionary.getOres("oreSilver").get(0), 1)); } } catch(Exception e) {} + /** Here we go through every Metallurgy metal set and add recipes to handle the new metals added + * There is no API way to iterate all the metal types, so we use hardcode :( */ + if(hooks.MetallurgyCoreLoaded){ + try{ + String[] setNames = {"base", "precious", "nether", "fantasy", "ender", "utility"}; + for (String setName : setNames ){ + for (IOreInfo oreInfo : MetallurgyAPI.getMetalSet(setName).getOreList().values()){ + switch (oreInfo.getType()) { + /** Alloy metal don't drop, they are only produced by combining other metals + * only adding crusher + */ + case ALLOY: { + if (oreInfo.getIngot() != null && oreInfo.getDust() != null){ + RecipeHandler.addCrusherRecipe(MekanismUtils.getStackWithSize(oreInfo.getIngot() ,1), MekanismUtils.getStackWithSize(oreInfo.getDust(),1)); + } + break; + } + + /** DROP-type ores normally drop something else then the ore itself, so here we add + * bonus items given by enrichment chamber if silk touch or other way gives the player the ore block + * Maybe add combiner recipe, but seems pointless now + */ + case DROP: { + ItemStack ore = oreInfo.getOre(); + ItemStack drop = oreInfo.getDrop(); + if(drop != null && ore != null){ + RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.getStackWithSize(ore, 1), MekanismUtils.getStackWithSize(drop, 12)); + //maybe combiner recipe too + } + break; + } + /** For all other types we don't really care, just try the general stencil*/ + default: { + ItemStack ore = oreInfo.getOre(); + ItemStack dust = oreInfo.getDust(); + ItemStack ingot = oreInfo.getIngot(); + if (ore != null && dust != null){ + RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.getStackWithSize(ore ,1), MekanismUtils.getStackWithSize(dust,2)); + } + if (ingot != null && dust != null){ + RecipeHandler.addCrusherRecipe(MekanismUtils.getStackWithSize(ingot ,1), MekanismUtils.getStackWithSize(dust,1)); + } + break; + } + } + } + } + } + + catch(Exception e) {} + } } + /** * Adds and registers all entities and tile entities. */ diff --git a/src/minecraft/mekanism/common/MekanismHooks.java b/src/minecraft/mekanism/common/MekanismHooks.java index 0e4eb3716..e993ba5c5 100644 --- a/src/minecraft/mekanism/common/MekanismHooks.java +++ b/src/minecraft/mekanism/common/MekanismHooks.java @@ -41,6 +41,9 @@ public final class MekanismHooks public boolean ForestryLoaded = false; public boolean TELoaded = false; + public boolean MetallurgyCoreLoaded = false; + public boolean MetallurgyBaseLoaded = false; + public void hook() { if(Loader.isModLoaded("IC2")) IC2Loaded = true; @@ -49,6 +52,10 @@ public final class MekanismHooks if(Loader.isModLoaded("BuildCraft|Energy")) BuildCraftLoaded = true; if(Loader.isModLoaded("Forestry")) ForestryLoaded = true; if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true; + if(Loader.isModLoaded("Metallurgy3Core")) { + MetallurgyCoreLoaded = true; + if(Loader.isModLoaded("Metallurgy3Base")) MetallurgyBaseLoaded = true; + } if(IC2Loaded) { diff --git a/src/minecraft/rebelkeithy/mods/metallurgy/api/IMetalSet.java b/src/minecraft/rebelkeithy/mods/metallurgy/api/IMetalSet.java new file mode 100644 index 000000000..4be266409 --- /dev/null +++ b/src/minecraft/rebelkeithy/mods/metallurgy/api/IMetalSet.java @@ -0,0 +1,10 @@ +package rebelkeithy.mods.metallurgy.api; + +import java.util.Map; + +public interface IMetalSet +{ + public IOreInfo getOreInfo(String name); + public IOreInfo getOreInfo(int metadata); + public Map getOreList(); +} diff --git a/src/minecraft/rebelkeithy/mods/metallurgy/api/IOreInfo.java b/src/minecraft/rebelkeithy/mods/metallurgy/api/IOreInfo.java new file mode 100644 index 000000000..531e26526 --- /dev/null +++ b/src/minecraft/rebelkeithy/mods/metallurgy/api/IOreInfo.java @@ -0,0 +1,29 @@ +package rebelkeithy.mods.metallurgy.api; + +import net.minecraft.item.ItemStack; + +public interface IOreInfo +{ + public String getName(); + public OreType getType(); + + public ItemStack getOre(); + public ItemStack getBlock(); + public ItemStack getBrick(); + + // Returns the itemstack of dust this ore crushes into, if no dust exists, returns null + public ItemStack getDust(); + + // Returns the itemstack of ingot for this ore, if no ingot exists, returns null + public ItemStack getIngot(); + + // If this ore drops something other than itself, this returns the ItemStack + // of the drop, otherwise returns null + public ItemStack getDrop(); + public int getDropAmountMin(); + public int getDropAmountMax(); + + // Returns an array of OreDictionary keys of the dusts the make this if it's an alloy + // if it's not an alloy, this returns null + public String[] getAlloyRecipe(); +} diff --git a/src/minecraft/rebelkeithy/mods/metallurgy/api/MetallurgyAPI.java b/src/minecraft/rebelkeithy/mods/metallurgy/api/MetallurgyAPI.java new file mode 100644 index 000000000..139fb148c --- /dev/null +++ b/src/minecraft/rebelkeithy/mods/metallurgy/api/MetallurgyAPI.java @@ -0,0 +1,34 @@ +package rebelkeithy.mods.metallurgy.api; + +import java.lang.reflect.Field; + +public class MetallurgyAPI +{ + + // Values for name: "base", "precious", "nether", "fantasy", "ender", "utility" + public static IMetalSet getMetalSet(String name) + { + try { + Class metallurgyMetals = Class.forName("rebelkeithy.mods.metallurgy.metals.MetallurgyMetals"); + Field set = metallurgyMetals.getField(name + "Set"); + return (IMetalSet) set.get(null); + } catch (NoSuchFieldException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } +} diff --git a/src/minecraft/rebelkeithy/mods/metallurgy/api/OreType.java b/src/minecraft/rebelkeithy/mods/metallurgy/api/OreType.java new file mode 100644 index 000000000..38c069325 --- /dev/null +++ b/src/minecraft/rebelkeithy/mods/metallurgy/api/OreType.java @@ -0,0 +1,18 @@ +package rebelkeithy.mods.metallurgy.api; + +public enum OreType { + + ORE(true), CATALYST(true), ALLOY(false), RESPAWN(true), DROP(true); + + private boolean generates; + + OreType(boolean generates) + { + this.generates = generates; + } + + public boolean generates() + { + return generates; + } +}