Disabled salvaging function of ore processors

There were several bugs that are not resolved but a few still remain.
The main one is near zero output from salvaged. Which even though its
not a big issue it still means that players lose items when they should
get stuff back.
This commit is contained in:
DarkGuardsman 2013-11-05 02:01:30 -05:00
parent 4537211850
commit 96d136a3f4
2 changed files with 51 additions and 43 deletions

View file

@ -5,7 +5,9 @@ import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -48,7 +50,7 @@ public class MachineRecipeHandler
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone); MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone);
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null); MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null);
//TODO replace these with ItemOreDirv //TODO replace these with ItemOreDirv glass shards
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.glass, Block.sand); MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.glass, Block.sand);
} }
@ -194,7 +196,8 @@ public class MachineRecipeHandler
} }
if (reList == null) if (reList == null)
{ {
reList = salvageItem(type, inputStack); //TODO Disabled due to bug and needs to be fixed to make the processors more functional
//reList = salvageItem(type, inputStack);
} }
return reList; return reList;
} }
@ -219,9 +222,9 @@ public class MachineRecipeHandler
* @return Array of all items salvaged */ * @return Array of all items salvaged */
public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack, boolean damage) public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack, boolean damage)
{ {
float bar = 0.3f; float bar = 0.1f;
//Allow tools and armor to be salvaged but at a very low rate //Allow tools and armor to be salvaged but at a very low rate
if (stack.isItemDamaged()) if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemTool) && stack.isItemDamaged())
{ {
bar = (stack.getItemDamage() / stack.getMaxDamage()); bar = (stack.getItemDamage() / stack.getMaxDamage());
} }
@ -248,20 +251,26 @@ public class MachineRecipeHandler
{ {
//TODO find a way around having to force recipe to be the same stack size of the salvage. Maybe percentage based salvaging or min stacksize from machine? //TODO find a way around having to force recipe to be the same stack size of the salvage. Maybe percentage based salvaging or min stacksize from machine?
ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy(), stack.stackSize); ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy(), stack.stackSize);
ItemStack[] reList = new ItemStack[recipeList.length]; if (recipeList != null)
for (int i = 0; i < recipeList.length; i++)
{ {
if (recipeList[i] != null && random.nextFloat() >= bar) ItemStack[] reList = new ItemStack[recipeList.length];
boolean items = false;
for (int i = 0; i < recipeList.length; i++)
{ {
reList[i] = recipeList[i]; if (random.nextFloat() >= bar)
if (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16)
{ {
reList[i].setItemDamage(0); reList[i] = recipeList[i].copy();
} items = true;
if (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16)
{
reList[i].setItemDamage(0);
}
}
} }
return items ? reList : null;
} }
return reList; return null;
} }
public static ItemStack[] getOuputNormal(ProcessorType type, ItemStack stack) public static ItemStack[] getOuputNormal(ProcessorType type, ItemStack stack)

View file

@ -212,45 +212,44 @@ public class AutoCraftingManager
} }
else if (object instanceof ShapelessRecipes) else if (object instanceof ShapelessRecipes)
{ {
return (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1]).clone(); return (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[9]).clone();
} }
else if (object instanceof ShapedOreRecipe) else if (object instanceof ShapedOreRecipe)
{ {
ShapedOreRecipe oreRecipe = (ShapedOreRecipe) object; ShapedOreRecipe oreRecipe = (ShapedOreRecipe) object;
Object[] recipeItems = (Object[]) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, oreRecipe, "input"); Object[] recipeItems = (Object[]) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, oreRecipe, "input");
List<ItemStack> actualResources = new ArrayList<ItemStack>(); ItemStack[] actualResources;
if (recipeItems != null) if (recipeItems != null)
{ {
for (Object obj : recipeItems) actualResources = new ItemStack[recipeItems.length];
for (int i = 0; i < recipeItems.length; i++)
{ {
if (obj instanceof ItemStack) if (recipeItems[i] instanceof ItemStack)
{ {
ItemStack recipeItem = (ItemStack) obj; actualResources[i] = ((ItemStack)recipeItems[i]).copy();
actualResources.add(recipeItem.copy());
} }
else if (obj instanceof ArrayList) else if (recipeItems[i] instanceof ArrayList)
{ {
Object[] ingredientsArray = ((ArrayList) obj).toArray(); Object[] ingredientsArray = ((ArrayList) recipeItems[i]).toArray();
for (int x = 0; x < ingredientsArray.length; x++) for (int x = 0; x < ingredientsArray.length; x++)
{ {
if (ingredientsArray[x] != null && ingredientsArray[x] instanceof ItemStack) if (ingredientsArray[x] != null && ingredientsArray[x] instanceof ItemStack)
{ {
ItemStack recipeItem = (ItemStack) ingredientsArray[x]; actualResources[i] = ((ItemStack)ingredientsArray[x]).copy();
actualResources.add(recipeItem.copy());
break; break;
} }
} }
} }
} }
return actualResources.toArray(new ItemStack[1]); return actualResources;
} }
} }
else if (object instanceof ShapelessOreRecipe) else if (object instanceof ShapelessOreRecipe)
{ {
ShapelessOreRecipe oreRecipe = (ShapelessOreRecipe) object; ShapelessOreRecipe oreRecipe = (ShapelessOreRecipe) object;
return (ItemStack[]) ((ArrayList) ReflectionHelper.getPrivateValue(ShapelessOreRecipe.class, oreRecipe, "input")).toArray(new ItemStack[1]).clone(); return (ItemStack[]) ((ArrayList) ReflectionHelper.getPrivateValue(ShapelessOreRecipe.class, oreRecipe, "input")).toArray(new ItemStack[9]).clone();
} }
} }
} }