Merge pull request #82 from fappoh/master

Metallurgy 3 compatibility
This commit is contained in:
Aidan 2013-06-01 18:36:23 -07:00
commit 20b206426d
6 changed files with 152 additions and 0 deletions

View file

@ -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,7 +980,59 @@ 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.

View file

@ -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)
{

View file

@ -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<String, IOreInfo> getOreList();
}

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -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;
}
}