From 9e38986f1e255f7a9f254143455f3cd0abe16923 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sat, 21 Sep 2013 18:03:39 -0400 Subject: [PATCH] worked on processor recipes There is a lot of work too do here. --- src/dark/api/ProcessorRecipes.java | 94 ++++++++++++---------- src/dark/core/common/CoreRecipeLoader.java | 2 + 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/dark/api/ProcessorRecipes.java b/src/dark/api/ProcessorRecipes.java index be34e0a4..06712fd5 100644 --- a/src/dark/api/ProcessorRecipes.java +++ b/src/dark/api/ProcessorRecipes.java @@ -31,13 +31,26 @@ public class ProcessorRecipes static { - createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.stone.blockID, 1, 0), new ItemStack(Block.cobblestone.blockID, 1, 0)); - createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.oreDiamond.blockID, 1, 0), new ItemStack(Item.diamond.itemID, 1, 0)); - createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.oreLapis.blockID, 1, 0), new ItemStack(Item.dyePowder.itemID, 4, ColorCode.BLUE.ordinal())); - createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.oreRedstone.blockID, 1, 0), new ItemStack(Item.redstone.itemID, 4, 0)); - createRecipe(ProcessorType.CRUSHER, new ItemStack(Block.oreEmerald.blockID, 1, 0), new ItemStack(Item.redstone.itemID, 4, 0)); + createRecipe(ProcessorType.CRUSHER, Block.stone, Block.cobblestone); + createRecipe(ProcessorType.CRUSHER, Block.oreDiamond, Item.diamond); + createRecipe(ProcessorType.CRUSHER, Block.oreLapis, new ItemStack(Item.dyePowder.itemID, 4, ColorCode.BLUE.ordinal())); + createRecipe(ProcessorType.CRUSHER, Block.oreRedstone, new ItemStack(Item.redstone.itemID, 4, 0)); + createRecipe(ProcessorType.CRUSHER, Block.oreEmerald, new ItemStack(Item.redstone.itemID, 4, 0)); createRecipe(ProcessorType.GRINDER, new ItemStack(Block.cobblestone.blockID, 1, 0), new ItemStack(Block.sand.blockID, 1, 0)); + createRecipe(ProcessorType.GRINDER, Block.glass, Block.sand); + + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, Block.stone, Block.cobblestone); + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, Block.cobblestoneMossy, Block.cobblestone); + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.GRINDER, Block.glass, Block.sand); + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Item.stick, null); + + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Block.stone, Block.cobblestone); + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone); + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Item.stick, null); + + //TODO replace these with ItemOreDirv + ProcessorRecipes.createSalvageDamageOutput(ProcessorType.CRUSHER, Block.glass, Block.sand); markOutputSalavageWithChance(ProcessorType.CRUSHER, new ItemStack(Block.chest, 1), .8f); markOutputSalavageWithChance(ProcessorType.CRUSHER, new ItemStack(Block.brick, 1), .7f); @@ -58,7 +71,7 @@ public class ProcessorRecipes if (input != null && output != null) { HashMap, ItemStack> map = type.recipes; - if (map != null && !map.containsKey(input)) + if (map != null && !map.containsKey(new Pair(input.itemID, input.getItemDamage()))) { map.put(new Pair(input.itemID, input.getItemDamage()), output); } @@ -81,7 +94,7 @@ public class ProcessorRecipes if (input != null && output != null) { HashMap, Pair> map = type.recipesChance; - if (map != null && !map.containsKey(input)) + if (map != null && !map.containsKey(new Pair(input.itemID, input.getItemDamage()))) { map.put(new Pair(input.itemID, input.getItemDamage()), new Pair(output, chance)); } @@ -99,7 +112,7 @@ public class ProcessorRecipes if (input != null && input != null) { HashMap, Float> map = type.recipesChanceSalvage; - if (map != null && !map.containsKey(input)) + if (map != null && !map.containsKey(new Pair(input.itemID, input.getItemDamage()))) { map.put(new Pair(input.itemID, input.getItemDamage()), chance); } @@ -117,9 +130,16 @@ public class ProcessorRecipes if (input != null && output != null) { HashMap, ItemStack> map = type.damagedOutput; - if (map != null && !map.containsKey(input)) + if (map != null) { - map.put(new Pair(input.itemID, input.getItemDamage()), output); + if (!map.containsKey(new Pair(input.itemID, input.getItemDamage()))) + { + map.put(new Pair(input.itemID, input.getItemDamage()), output); + } + else if (map.get(new Pair(input.itemID, input.getItemDamage())) == null) + { + map.put(new Pair(input.itemID, input.getItemDamage()), output); + } } } } @@ -160,37 +180,30 @@ public class ProcessorRecipes HashMap, Float> mapSalvage = type.recipesChanceSalvage; HashMap, ItemStack> altSalvageMap = type.damagedOutput; Pair blockSet = new Pair(stack.itemID, stack.getItemDamage()); - if (map == null) + + //Read normal recipe map for outputs + if (map != null) { - return null; - } - ItemStack re = map.get(new Pair(stack.itemID, -1)); - if (re != null) - { - return new ItemStack[] { re }; - } - re = map.get(blockSet); - if (re != null) - { - return new ItemStack[] { re }; + ItemStack re = map.get(new Pair(stack.itemID, -1)); + if (re != null) + { + return new ItemStack[] { convert(re) }; + } + re = map.get(blockSet); + if (re != null) + { + return new ItemStack[] { convert(re) }; + } } + + //Read chance output map Pair ree = mapChance.get(blockSet); if (ree != null && random.nextFloat() >= ree.getValue()) { - return new ItemStack[] { ree.getKey() }; - } - float chance = 0; - try - { - chance = mapSalvage != null ? mapSalvage.get(blockSet) : 0; - } - catch (Exception e) - { - } - if (chance == 0) - { - chance = .1f; + return new ItemStack[] { convert(ree.getKey()) }; } + + //Start salvaging items ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy()); ItemStack[] reList = null; if (recipeList != null) @@ -198,20 +211,17 @@ public class ProcessorRecipes reList = new ItemStack[recipeList.length]; for (int i = 0; i < recipeList.length; i++) { - if (recipeList[i] != null && random.nextFloat() >= chance) + if (recipeList[i] != null && random.nextFloat() >= .3f) { int meta = recipeList[i].getItemDamage(); - NBTTagCompound tag = recipeList[i].getTagCompound(); + reList[i] = recipeList[i]; if (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16) { - meta = 0; - + reList[i].setItemDamage(0); } - reList[i] = new ItemStack(recipeList[i].itemID, recipeList[i].stackSize, meta); - reList[i].setTagCompound(tag); if (damageSalvage && altSalvageMap != null && altSalvageMap.containsKey(new Pair(reList[i].itemID, reList[i].getItemDamage()))) { - reList[i] = altSalvageMap.get(new Pair(reList[i].itemID, reList[i].getItemDamage())); + reList[i] = convert(altSalvageMap.get(new Pair(reList[i].itemID, reList[i].getItemDamage()))); } } } diff --git a/src/dark/core/common/CoreRecipeLoader.java b/src/dark/core/common/CoreRecipeLoader.java index 6b62194f..4bb6884a 100644 --- a/src/dark/core/common/CoreRecipeLoader.java +++ b/src/dark/core/common/CoreRecipeLoader.java @@ -82,9 +82,11 @@ public class CoreRecipeLoader extends RecipeLoader //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)); + //Stone recipes ProcessorRecipes.createRecipe(ProcessorType.GRINDER, Block.stone, EnumMaterial.getStack(EnumMaterial.STONE, EnumOrePart.DUST, 1));