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.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary;
@ -48,7 +50,7 @@ public class MachineRecipeHandler
MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone);
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);
}
@ -194,7 +196,8 @@ public class MachineRecipeHandler
}
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;
}
@ -219,9 +222,9 @@ public class MachineRecipeHandler
* @return Array of all items salvaged */
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
if (stack.isItemDamaged())
if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemTool) && stack.isItemDamaged())
{
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?
ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy(), stack.stackSize);
ItemStack[] reList = new ItemStack[recipeList.length];
for (int i = 0; i < recipeList.length; i++)
if (recipeList != null)
{
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 (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16)
if (random.nextFloat() >= bar)
{
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)

View file

@ -212,45 +212,44 @@ public class AutoCraftingManager
}
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)
{
ShapedOreRecipe oreRecipe = (ShapedOreRecipe) object;
Object[] recipeItems = (Object[]) ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, oreRecipe, "input");
List<ItemStack> actualResources = new ArrayList<ItemStack>();
ItemStack[] actualResources;
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.add(recipeItem.copy());
actualResources[i] = ((ItemStack)recipeItems[i]).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++)
{
if (ingredientsArray[x] != null && ingredientsArray[x] instanceof ItemStack)
{
ItemStack recipeItem = (ItemStack) ingredientsArray[x];
actualResources.add(recipeItem.copy());
actualResources[i] = ((ItemStack)ingredientsArray[x]).copy();
break;
}
}
}
}
return actualResources.toArray(new ItemStack[1]);
return actualResources;
}
}
else if (object instanceof ShapelessOreRecipe)
{
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();
}
}
}