Fixed Harvest sigil in armour giving bad items

Finished optimization of compression handler.
This commit is contained in:
WayofTime 2015-03-11 19:19:17 -04:00
parent e21f6941ba
commit d7d8aedd42
8 changed files with 259 additions and 117 deletions

View file

@ -9,11 +9,7 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
public class StorageBlockCraftingManager
@ -28,96 +24,97 @@ public class StorageBlockCraftingManager
public void addStorageBlockRecipes()
{
this.recipes = new StorageBlockCraftingRecipeAssimilator().getPackingOptions();
this.recipes = new StorageBlockCraftingRecipeAssimilator().getPackingRecipes();
List<IRecipe> tempRecipeList = new LinkedList();
World world = DimensionManager.getWorld(0);
for(Object obj : this.recipes)
{
if(obj instanceof IRecipe)
{
IRecipe recipe = (IRecipe)obj;
ItemStack outputStack = recipe.getRecipeOutput();
if(outputStack == null || outputStack.getItem() == null)
{
continue;
}
if(recipe instanceof ShapedRecipes)
{
ShapedRecipes sRecipe = (ShapedRecipes)recipe;
ItemStack[] input = sRecipe.recipeItems;
if(outputStack.stackSize == 1 && (input.length == 9 || input.length == 4))
{
tempRecipeList.add(recipe);
}else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.length == 1)
{
tempRecipeList.add(recipe);
}
}
else if(recipe instanceof ShapelessRecipes)
{
ShapelessRecipes sRecipe = (ShapelessRecipes)recipe;
List input = sRecipe.recipeItems;
if(outputStack.stackSize == 1 && (input.size() == 9 || input.size() == 4))
{
Object obj1 = input.get(0);
if(obj1 != null)
{
boolean allMatch = true;
for(Object obj2 : input)
{
if(obj2 == null || !obj2.equals(obj1))
{
allMatch = false;
break;
}
}
if(allMatch)
{
tempRecipeList.add(recipe);
}
}
}else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.size() == 1)
{
tempRecipeList.add(recipe);
}
}
else if((outputStack.stackSize == 1 && (recipe.getRecipeSize() == 9 || recipe.getRecipeSize() == 4)) || ((outputStack.stackSize == 9 || outputStack.stackSize == 4) && recipe.getRecipeSize() == 1))
{
tempRecipeList.add(recipe);
continue;
}
}
}
List<IRecipe> tempRecipeList2 = new LinkedList();
for(Object obj : tempRecipeList)
{
if(obj instanceof IRecipe)
{
IRecipe recipe = (IRecipe)obj;
ItemStack outputStack = recipe.getRecipeOutput();
if(outputStack == null || outputStack.getItem() == null)
{
continue;
}
if(isResultStackReversible(outputStack, 2, world, tempRecipeList) || isResultStackReversible(outputStack, 3, world, tempRecipeList))
{
tempRecipeList2.add(recipe);
AlchemicalWizardry.logger.info("Now adding recipe for " + outputStack + " to the compression handler.");
}
}
}
this.recipes = tempRecipeList2;
System.out.println("Total number of compression recipes: " + this.recipes.size());
// List<IRecipe> tempRecipeList = new LinkedList();
//
// World world = DimensionManager.getWorld(0);
//
// for(Object obj : this.recipes)
// {
// if(obj instanceof IRecipe)
// {
// IRecipe recipe = (IRecipe)obj;
// ItemStack outputStack = recipe.getRecipeOutput();
// if(outputStack == null || outputStack.getItem() == null)
// {
// continue;
// }
//
// if(recipe instanceof ShapedRecipes)
// {
// ShapedRecipes sRecipe = (ShapedRecipes)recipe;
// ItemStack[] input = sRecipe.recipeItems;
//
// if(outputStack.stackSize == 1 && (input.length == 9 || input.length == 4))
// {
// tempRecipeList.add(recipe);
// }else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.length == 1)
// {
// tempRecipeList.add(recipe);
// }
// }
// else if(recipe instanceof ShapelessRecipes)
// {
// ShapelessRecipes sRecipe = (ShapelessRecipes)recipe;
// List input = sRecipe.recipeItems;
//
// if(outputStack.stackSize == 1 && (input.size() == 9 || input.size() == 4))
// {
// Object obj1 = input.get(0);
// if(obj1 != null)
// {
// boolean allMatch = true;
// for(Object obj2 : input)
// {
// if(obj2 == null || !obj2.equals(obj1))
// {
// allMatch = false;
// break;
// }
// }
// if(allMatch)
// {
// tempRecipeList.add(recipe);
// }
// }
//
// }else if((outputStack.stackSize == 9 || outputStack.stackSize == 4) && input.size() == 1)
// {
// tempRecipeList.add(recipe);
// }
// }
// else if((outputStack.stackSize == 1 && (recipe.getRecipeSize() == 9 || recipe.getRecipeSize() == 4)) || ((outputStack.stackSize == 9 || outputStack.stackSize == 4) && recipe.getRecipeSize() == 1))
// {
// tempRecipeList.add(recipe);
// continue;
// }
// }
// }
//
// List<IRecipe> tempRecipeList2 = new LinkedList();
//
// for(Object obj : tempRecipeList)
// {
// if(obj instanceof IRecipe)
// {
// IRecipe recipe = (IRecipe)obj;
// ItemStack outputStack = recipe.getRecipeOutput();
// if(outputStack == null || outputStack.getItem() == null)
// {
// continue;
// }
//
// if(isResultStackReversible(outputStack, 2, world, tempRecipeList) || isResultStackReversible(outputStack, 3, world, tempRecipeList))
// {
// tempRecipeList2.add(recipe);
// AlchemicalWizardry.logger.info("Now adding recipe for " + outputStack + " to the compression handler.");
// }
// }
// }
//
// this.recipes = tempRecipeList2;
}
private static boolean isResultStackReversible(ItemStack stack, int gridSize, World world, List list)