Worked on ore dictionary support
This commit is contained in:
parent
3b24c5b806
commit
0808668742
4 changed files with 38 additions and 64 deletions
|
@ -303,7 +303,7 @@ public class MachineRecipeHandler
|
|||
|
||||
public static void parseOreNames(Configuration config)
|
||||
{
|
||||
if (!loadedOres && CoreRecipeLoader.itemMetals instanceof ItemOreDirv)
|
||||
if (!loadedOres && CoreRecipeLoader.itemMetals != null && config.get("Ore", "processOreDictionary", true, "Scans the ore dictionary and adds other mods ore to the machine recipes").getBoolean(true))
|
||||
{
|
||||
for (EnumMaterial mat : EnumMaterial.values())
|
||||
{ //Ingots
|
||||
|
@ -320,7 +320,7 @@ public class MachineRecipeHandler
|
|||
dusts.addAll(OreDictionary.getOres(mat.simpleName + "dust"));
|
||||
for (ItemStack du : dusts)
|
||||
{
|
||||
if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("OreParser", "OverrideDustSmelthing", true).getBoolean(true))
|
||||
if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideDustSmelthing", true, "Overrides other mods dust smelting so the ingots smelt as the same item.").getBoolean(true))
|
||||
{
|
||||
FurnaceRecipes.smelting().addSmelting(du.itemID, du.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f);
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ public class MachineRecipeHandler
|
|||
if (mat.shouldCreateItem(EnumOrePart.PLATES))
|
||||
{
|
||||
GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.PLATES, 1), new Object[] { pla });
|
||||
if (config.get("OreParser", "ForcePlateToIngotDM", true).getBoolean(true))
|
||||
if (config.get("Ore", "OverridePlateCrafting", true, "Overrides other mods metal plate crafting. As well creates new recipes for mod ingots without plate crafting.").getBoolean(true))
|
||||
{
|
||||
GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.INGOTS, 4), new Object[] { pla });
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class MachineRecipeHandler
|
|||
{
|
||||
MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, ore, mat.getStack(EnumOrePart.DUST, 1), 1, 3);
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("OreParser", "OverrideOreSmelthing", true).getBoolean(true))
|
||||
if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideOreSmelthing", true, "Overrides other mods smelting recipes for ingots").getBoolean(true))
|
||||
{
|
||||
FurnaceRecipes.smelting().addSmelting(ore.itemID, ore.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f);
|
||||
}
|
||||
|
|
|
@ -79,10 +79,10 @@ public enum EnumMaterial
|
|||
* @param mat - material
|
||||
* @param part - part
|
||||
* @return new ItemStack created from the two enums as long as everything goes right */
|
||||
public static ItemStack getStack(EnumMaterial mat, EnumOrePart part, int ammount)
|
||||
public static ItemStack getStack(Item item, EnumMaterial mat, EnumOrePart part, int ammount)
|
||||
{
|
||||
ItemStack reStack = null;
|
||||
if (CoreRecipeLoader.itemMetals instanceof ItemOreDirv && mat != null && part != null)
|
||||
if (mat != null && part != null)
|
||||
{
|
||||
if (part == EnumOrePart.INGOTS)
|
||||
{
|
||||
|
@ -97,11 +97,16 @@ public enum EnumMaterial
|
|||
}
|
||||
int meta = mat.ordinal() * itemCountPerMaterial;
|
||||
meta += part.ordinal();
|
||||
return new ItemStack(CoreRecipeLoader.itemMetals.itemID, ammount, meta);
|
||||
return new ItemStack(item, ammount, meta);
|
||||
}
|
||||
return reStack;
|
||||
}
|
||||
|
||||
public static ItemStack getStack(EnumMaterial mat, EnumOrePart part, int ammount)
|
||||
{
|
||||
return getStack(CoreRecipeLoader.itemMetals, mat, part, ammount);
|
||||
}
|
||||
|
||||
public ItemStack getStack(EnumOrePart part)
|
||||
{
|
||||
return this.getStack(part, 1);
|
||||
|
@ -112,6 +117,16 @@ public enum EnumMaterial
|
|||
return getStack(this, part, ammount);
|
||||
}
|
||||
|
||||
public ItemStack getStack(Item item, EnumOrePart part)
|
||||
{
|
||||
return this.getStack(item, part, 1);
|
||||
}
|
||||
|
||||
public ItemStack getStack(Item item, EnumOrePart part, int ammount)
|
||||
{
|
||||
return getStack(item, this, part, ammount);
|
||||
}
|
||||
|
||||
public static Icon getIcon(int metadata)
|
||||
{
|
||||
int mat = metadata / EnumMaterial.itemCountPerMaterial;
|
||||
|
@ -142,17 +157,22 @@ public enum EnumMaterial
|
|||
|
||||
public static String getOreName(EnumMaterial mat, EnumOrePart part)
|
||||
{
|
||||
return mat.simpleName + part.simpleName;
|
||||
return mat.getOreName(part);
|
||||
}
|
||||
|
||||
public String getOreName(EnumOrePart part)
|
||||
{
|
||||
return this.simpleName + part.simpleName;
|
||||
return this.simpleName.toLowerCase() + part.simpleName;
|
||||
}
|
||||
|
||||
public static String getOreNameReverse(EnumMaterial mat, EnumOrePart part)
|
||||
{
|
||||
return mat.getOreNameReverse(part);
|
||||
}
|
||||
|
||||
public String getOreNameReverse(EnumOrePart part)
|
||||
{
|
||||
return part.simpleName + this.simpleName;
|
||||
return part.simpleName.toLowerCase() + this.simpleName;
|
||||
}
|
||||
|
||||
public boolean shouldCreateItem(EnumOrePart part)
|
||||
|
|
|
@ -102,14 +102,15 @@ public class ItemOreDirv extends ItemBasic implements IExtraItemInfo
|
|||
{
|
||||
for (EnumOrePart part : EnumOrePart.values())
|
||||
{
|
||||
ItemStack stack = EnumMaterial.getStack(mat, part, 1);
|
||||
if (stack != null && mat.shouldCreateItem(part) && mat.itemIcons[part.ordinal()] != null)
|
||||
if (mat.shouldCreateItem(part))
|
||||
{
|
||||
OreDictionary.registerOre(EnumOrePart.getFullName(stack.getItemDamage()), stack);
|
||||
System.out.println(" N: " + mat.getOreName(part) + " R:" + mat.getOreNameReverse(part));
|
||||
String B = mat.getOreNameReverse(part);
|
||||
OreDictionary.registerOre(mat.getOreName(part), mat.getStack(this, part, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(part), mat.getStack(this, part, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
|
|
|
@ -178,54 +178,6 @@ public class DarkMain extends ModPrefab
|
|||
if (CoreRecipeLoader.itemMetals != null)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(CoreRecipeLoader.itemMetals);
|
||||
//Ore material recipe loop
|
||||
for (EnumMaterial mat : EnumMaterial.values())
|
||||
{
|
||||
if (mat.shouldCreateItem(EnumOrePart.INGOTS))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.INGOTS), mat.getStack(EnumOrePart.INGOTS, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.INGOTS), mat.getStack(EnumOrePart.INGOTS, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.RUBBLE))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.RUBBLE), mat.getStack(EnumOrePart.RUBBLE, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.RUBBLE), mat.getStack(EnumOrePart.RUBBLE, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.DUST))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.DUST), mat.getStack(EnumOrePart.DUST, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.DUST), mat.getStack(EnumOrePart.DUST, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.SCRAPS))
|
||||
{
|
||||
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.SCRAPS), mat.getStack(EnumOrePart.SCRAPS, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.SCRAPS), mat.getStack(EnumOrePart.SCRAPS, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.TUBE))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
|
||||
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.ROD))
|
||||
{
|
||||
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.ROD), mat.getStack(EnumOrePart.ROD, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.ROD), mat.getStack(EnumOrePart.ROD, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.PLATES))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.PLATES), mat.getStack(EnumOrePart.PLATES, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.PLATES), mat.getStack(EnumOrePart.PLATES, 1));
|
||||
}
|
||||
if (mat.shouldCreateItem(EnumOrePart.GEARS))
|
||||
{
|
||||
OreDictionary.registerOre(mat.getOreName(EnumOrePart.GEARS), mat.getStack(EnumOrePart.GEARS, 1));
|
||||
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.GEARS), mat.getStack(EnumOrePart.GEARS, 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
FMLLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
|
||||
proxy.init();
|
||||
|
@ -246,6 +198,7 @@ public class DarkMain extends ModPrefab
|
|||
DMCreativeTab.tabIndustrial.itemStack = EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.GEARS, 1);
|
||||
}
|
||||
MachineRecipeHandler.parseOreNames(CONFIGURATION);
|
||||
CONFIGURATION.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -294,8 +247,8 @@ public class DarkMain extends ModPrefab
|
|||
CoreRecipeLoader.itemDiggingTool = ModObjectRegistry.createNewItem("ItemDiggingTools", DarkMain.MOD_ID, ItemCommonTool.class, true);
|
||||
CoreRecipeLoader.itemVehicleTest = ModObjectRegistry.createNewItem("ItemVehicleTest", DarkMain.MOD_ID, ItemVehicleSpawn.class, true);
|
||||
CoreRecipeLoader.itemFluidCan = ModObjectRegistry.createNewItem("ItemFluidCan", DarkMain.MOD_ID, ItemFluidCan.class, true);
|
||||
|
||||
CONFIGURATION.save();
|
||||
//Config saves in post init to allow for other feature to access it
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue