Worked on processor recipes

Also added damage output to normal processors so that some items don't
return in a clean form. Cases are for planks, ingots, plates, and some
blocks. This is to set the way for salvager machines later down the
road. In which will cost a lot and take a lot of time. Over normal
processor salvaging that will mess up just about anything that goes into
it.
This commit is contained in:
DarkGuardsman 2013-09-21 13:45:35 -04:00
parent 4e1204ed7b
commit 89944e03fc
5 changed files with 125 additions and 37 deletions

View file

@ -11,7 +11,7 @@ import dark.core.prefab.helpers.AutoCraftingManager;
import dark.core.prefab.helpers.Pair;
/** Recipes for ore processor machines
*
*
* @author DarkGuardsman */
public class ProcessorRecipes
{
@ -25,6 +25,7 @@ public class ProcessorRecipes
public HashMap<Pair<Integer, Integer>, ItemStack> recipes = new HashMap();
public HashMap<Pair<Integer, Integer>, Pair<ItemStack, Float>> recipesChance = new HashMap();
public HashMap<Pair<Integer, Integer>, Float> recipesChanceSalvage = new HashMap();
public HashMap<Pair<Integer, Integer>, ItemStack> damagedOutput = new HashMap();
}
@ -32,10 +33,16 @@ public class ProcessorRecipes
{
createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.stone.blockID, 1, 0), new ItemStack(Block.cobblestone.blockID, 1, 0));
createRecipe(ProcessorType.GRINDER, new ItemStack(Block.cobblestone.blockID, 1, 0), new ItemStack(Block.sand.blockID, 1, 0));
createSalvageRecipe(ProcessorType.CRUSHER, new ItemStack(Block.chest, 1), .8f);
markOutputSalavageWithChance(ProcessorType.CRUSHER, new ItemStack(Block.chest, 1), .8f);
markOutputSalavageWithChance(ProcessorType.CRUSHER, new ItemStack(Block.brick, 1), .7f);
}
/** Creates a simple one itemStack in one ItemStack out. Itemstack output can actual have a stack
* size larger than one
*
* @param type - processor type
* @param in - input item, stacksize is ignored
* @param out - ouput item */
public static void createRecipe(ProcessorType type, Object in, Object out)
{
if (in != null && out != null && type != null)
@ -53,6 +60,12 @@ public class ProcessorRecipes
}
}
/** Creates a recipe that has a chance of failing
*
* @param type - processor type
* @param in - input item stack, stack size is ignored
* @param out - output item stack, stack size is used
* @param chance - chance to fail with 1 being zero chance and zero being 100% chance */
public static void createRecipeWithChance(ProcessorType type, Object in, Object out, float chance)
{
if (in != null && out != null && type != null)
@ -70,7 +83,9 @@ public class ProcessorRecipes
}
}
public static void createSalvageRecipe(ProcessorType type, Object in, float chance)
/** Not so much of a recipe but it applies a change on the item. TODO improve and control actual
* output of the recipe */
public static void markOutputSalavageWithChance(ProcessorType type, Object in, float chance)
{
if (in != null && type != null)
{
@ -86,6 +101,25 @@ public class ProcessorRecipes
}
}
/** Used to track items that should be converted to different items during salvaging. */
public static void createSalvageDamageOutput(ProcessorType type, Object in, Object out)
{
if (in != null && out != null && type != null)
{
ItemStack input = convert(in);
ItemStack output = convert(out);
if (input != null && output != null)
{
HashMap<Pair<Integer, Integer>, ItemStack> map = type.damagedOutput;
if (map != null && !map.containsKey(input))
{
map.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), output);
}
}
}
}
/** Converts an object input into an itemstack for use */
private static ItemStack convert(Object object)
{
if (object instanceof ItemStack)
@ -103,7 +137,13 @@ public class ProcessorRecipes
return null;
}
public static ItemStack[] getOuput(ProcessorType type, ItemStack stack)
/** Gets the lit of items that are created from the input item stack. General this will be an
* array of one item. However, in salavaging cases it can be up to 8 items.
*
* @param type - Processor type
* @param stack - item stack input ignores stacksize
* @return array of itemStacks */
public static ItemStack[] getOuput(ProcessorType type, ItemStack stack, boolean damageSalvage)
{
if (stack == null || type == null || stack.getItem() == null)
{
@ -112,6 +152,7 @@ public class ProcessorRecipes
HashMap<Pair<Integer, Integer>, ItemStack> map = type.recipes;
HashMap<Pair<Integer, Integer>, Pair<ItemStack, Float>> mapChance = type.recipesChance;
HashMap<Pair<Integer, Integer>, Float> mapSalvage = type.recipesChanceSalvage;
HashMap<Pair<Integer, Integer>, ItemStack> altSalvageMap = type.damagedOutput;
Pair<Integer, Integer> blockSet = new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage());
if (map == null)
{
@ -162,6 +203,10 @@ public class ProcessorRecipes
}
reList[i] = new ItemStack(recipeList[i].itemID, recipeList[i].stackSize, meta);
reList[i].setTagCompound(tag);
if (damageSalvage && altSalvageMap != null && altSalvageMap.containsKey(new Pair<Integer, Integer>(reList[i].itemID, reList[i].getItemDamage())))
{
reList[i] = altSalvageMap.get(new Pair<Integer, Integer>(reList[i].itemID, reList[i].getItemDamage()));
}
}
}
}

View file

@ -5,10 +5,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import cpw.mods.fml.common.registry.GameRegistry;
import dark.api.ProcessorRecipes;
import dark.api.ProcessorRecipes.ProcessorType;
import dark.core.common.blocks.BlockBasalt;
import dark.core.common.blocks.BlockOre.OreData;
import dark.core.common.items.EnumMaterial;
import dark.core.common.items.EnumOrePart;
import dark.core.common.items.ItemOreDirv;
import dark.core.common.items.ItemParts;
import dark.core.common.items.ItemParts.Parts;
import dark.core.common.items.ItemWrench;
@ -39,13 +42,12 @@ public class CoreRecipeLoader extends RecipeLoader
super.loadRecipes();
new RecipeGrid(new ItemStack(itemTool, 1, 0), 3, 2).setRowOne("ironTube", "valvePart", "ironTube").setRowTwo(null, "ironTube", null).RegisterRecipe();
this.loadSmeltingRecipes();
this.loadParts();
}
public void loadParts()
{
if (itemParts != null)
if (itemParts instanceof ItemParts)
{
ironTube = new ItemStack(itemParts, 1, Parts.Iron.ordinal());
bronzeTube = new ItemStack(itemParts, 1, Parts.Bronze.ordinal());
@ -74,21 +76,69 @@ public class CoreRecipeLoader extends RecipeLoader
new RecipeGrid(unfinishedTank).setRowOne(null, Item.ingotIron, null).setRowTwo(Item.ingotIron, null, Item.ingotIron).setRowThree(null, Item.ingotIron, null).RegisterRecipe();
new RecipeGrid(unfinishedTank).setRowOne(null, bronze, null).setRowTwo(bronze, null, bronze).setRowThree(null, bronze, null).RegisterRecipe();
}
}
public void loadSmeltingRecipes()
{
if (blockOre != null && itemMetals != null)
if (itemMetals instanceof ItemOreDirv)
{
//Alt salvaging item list
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, Block.wood, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.DUST, 3));
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, Block.planks, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.DUST, 1));
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Block.wood, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.SCRAPS, 3));
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Block.planks, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.SCRAPS, 1));
for (int i = 0; i < EnumMaterial.values().length; i++)
//Stone recipes
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, Block.stone, EnumMaterial.getStack(EnumMaterial.STONE, EnumOrePart.DUST, 1));
//Wood recipes
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, Block.wood, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.DUST, 3));
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, Block.planks, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.DUST, 1));
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, Block.wood, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.SCRAPS, 3));
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, Block.planks, EnumMaterial.getStack(EnumMaterial.WOOD, EnumOrePart.SCRAPS, 1));
//Gold Recipes
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, Block.blockIron, EnumMaterial.getStack(EnumMaterial.GOLD, EnumOrePart.SCRAPS, 8));
//Iron Recipes
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, Block.blockGold, EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.SCRAPS, 8));
//Ore material recipe loop
for (EnumMaterial mat : EnumMaterial.values())
{
if (EnumMaterial.values()[i].shouldCreateItem(EnumOrePart.DUST) && EnumMaterial.values()[i] != EnumMaterial.WOOD && EnumMaterial.values()[i] != EnumMaterial.COAL)
{
FurnaceRecipes.smelting().addSmelting(itemMetals.itemID, i + 20, new ItemStack(itemMetals.itemID, 1, 40 + i), 0.6f);
}
ItemStack dust = EnumMaterial.getStack(mat, EnumOrePart.DUST, 2);
ItemStack ingot = EnumMaterial.getStack(mat, EnumOrePart.INGOTS, 1);
ItemStack scraps = EnumMaterial.getStack(mat, EnumOrePart.SCRAPS, 1);
ItemStack plates = EnumMaterial.getStack(mat, EnumOrePart.PLATES, 1);
ItemStack rubble = EnumMaterial.getStack(mat, EnumOrePart.RUBBLE, 1);
//Smelting recipes
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), ingot, 0.6f);
FurnaceRecipes.smelting().addSmelting(scraps.itemID, scraps.getItemDamage(), ingot, 0.6f);
//Dust recipes
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, rubble, dust);
dust.stackSize = 1;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, scraps, dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, ingot, dust);
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, ingot, dust);
// Salvaging recipe
scraps.stackSize = 3;
dust.stackSize = 2;
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, plates, scraps);
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, plates, scraps);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, plates, dust);
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, plates, dust);
scraps.stackSize = 2;
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, rubble, scraps);
scraps.stackSize = 1;
ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, ingot, scraps);
//Press recipes TODO set this up another way since input.stackSize can only equal 1
//ingot.stackSize = 3;
//ProcessorRecipes.createRecipe(ProcessorType.PRESS, ingot, plates);
}
}
}
public void loadStainGlass()

View file

@ -81,18 +81,8 @@ public class BlockOre extends Block implements IExtraObjectInfo
if (CoreRecipeLoader.itemMetals instanceof ItemOreDirv)
{
ItemStack oreStack = new ItemStack(this.blockID, 1, data.ordinal());
ItemStack dust = EnumMaterial.getStack(data.mat, EnumOrePart.DUST, 1);
ItemStack ingot = EnumMaterial.getStack(data.mat, EnumOrePart.INGOTS, 1);
FurnaceRecipes.smelting().addSmelting(this.blockID, data.ordinal(),ingot , 0.6f);
FurnaceRecipes.smelting().addSmelting(this.blockID, data.ordinal(), EnumMaterial.getStack(data.mat, EnumOrePart.INGOTS, 1), 0.6f);
ProcessorRecipes.createRecipe(ProcessorType.CRUSHER, oreStack, EnumMaterial.getStack(data.mat, EnumOrePart.RUBBLE, 1));
dust.stackSize = 2;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.RUBBLE, 1), dust);
dust.stackSize = 1;
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.SCRAPS, 1), dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, ingot, dust);
ProcessorRecipes.createRecipe(ProcessorType.GRINDER, EnumMaterial.getStack(data.mat, EnumOrePart.PLATES, 1), EnumMaterial.getStack(data.mat, EnumOrePart.SCRAPS, 2));
ProcessorRecipes.createRecipe(ProcessorType.PRESS, EnumMaterial.getStack(data.mat, EnumOrePart.INGOTS, 3), EnumMaterial.getStack(data.mat, EnumOrePart.PLATES, 1));
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), ingot, 0.6f);
}
}
}

View file

@ -18,15 +18,16 @@ public enum EnumMaterial
{
WOOD("Wood", EnumOrePart.INGOTS, EnumOrePart.PLATES, EnumOrePart.RUBBLE, EnumOrePart.ROD),
STONE("Stone", EnumOrePart.INGOTS),
COPPER("Copper"),
TIN("Tin", EnumOrePart.GEARS, EnumOrePart.TUBE),
IRON("Iron", EnumOrePart.INGOTS),
OBBY("Obby", EnumOrePart.INGOTS, EnumOrePart.RUBBLE),
GOLD("Gold", EnumOrePart.GEARS, EnumOrePart.INGOTS),
COAL("Coal", EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE),
COPPER("Copper"),
TIN("Tin", EnumOrePart.GEARS, EnumOrePart.TUBE),
LEAD("Lead", EnumOrePart.GEARS, EnumOrePart.TUBE),
ALUMINIUM("Aluminum", EnumOrePart.GEARS, EnumOrePart.TUBE),
SILVER("Silver", EnumOrePart.GEARS),
GOLD("Gold", EnumOrePart.GEARS, EnumOrePart.INGOTS),
COAL("Coal", EnumOrePart.GEARS, EnumOrePart.TUBE, EnumOrePart.PLATES, EnumOrePart.RUBBLE),
STEEL("Steel", EnumOrePart.RUBBLE),
BRONZE("Bronze", EnumOrePart.RUBBLE);
@ -66,12 +67,13 @@ public enum EnumMaterial
{
if (part == EnumOrePart.INGOTS)
{
switch (EnumMaterial.IRON)
if (mat == EnumMaterial.IRON)
{
case IRON:
return new ItemStack(Item.ingotIron, 1);
case GOLD:
return new ItemStack(Item.ingotGold, 1);
return new ItemStack(Item.ingotIron, 1);
}
else if (mat == EnumMaterial.GOLD)
{
return new ItemStack(Item.ingotGold, 1);
}
}
int meta = mat.ordinal() * itemCountPerMaterial;

View file

@ -207,6 +207,7 @@ public class ModObjectRegistry
extraBlockConfig.save();
}
((IExtraObjectInfo) block).loadOreNames();
((IExtraObjectInfo) block).loadRecipes();
Set<Pair<String, Class<? extends TileEntity>>> tileListNew = new HashSet<Pair<String, Class<? extends TileEntity>>>();
((IExtraObjectInfo) block).getTileEntities(block.blockID, tileListNew);
for (Pair<String, Class<? extends TileEntity>> par : tileListNew)