Get the Aludel working again

This commit is contained in:
pahimar 2014-07-06 12:14:45 -04:00
parent 469fa9f5d2
commit f8df05268d
3 changed files with 53 additions and 30 deletions

View file

@ -1,6 +1,7 @@
package com.pahimar.ee3.handler;
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
import com.pahimar.ee3.recipe.RecipesAludel;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.item.crafting.CraftingManager;
@ -11,6 +12,7 @@ public class CraftingHandler
{
// Add in the ability to dye Alchemical Bags
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
RecipesAludel.getInstance();
}
@SubscribeEvent

View file

@ -2,7 +2,6 @@ package com.pahimar.ee3.item.crafting;
import com.pahimar.ee3.exchange.OreStack;
import com.pahimar.ee3.exchange.WrappedStack;
import com.pahimar.ee3.util.ItemHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
@ -29,24 +28,6 @@ public class RecipeAludel
this.dustStack = dustStack.copy();
}
public boolean matches(ItemStack inputStack, ItemStack dustStack)
{
if (OreDictionary.getOreID(inputStack) != -1)
{
if (matches(new WrappedStack(new OreStack(inputStack)), dustStack))
{
return matches(new WrappedStack(new OreStack(inputStack)), dustStack);
}
}
return matches(new WrappedStack(inputStack), dustStack);
}
public boolean matches(WrappedStack inputStack, ItemStack dustStack)
{
return compareStacks(this.inputStack, inputStack) && compareItemStacks(this.dustStack, dustStack);
}
private static boolean compareStacks(WrappedStack wrappedStack1, WrappedStack wrappedStack2)
{
if (wrappedStack1 != null && wrappedStack1.getWrappedStack() != null && wrappedStack2 != null && wrappedStack2.getWrappedStack() != null)
@ -74,7 +55,46 @@ public class RecipeAludel
private static boolean compareItemStacks(ItemStack itemStack1, ItemStack itemStack2)
{
return ItemHelper.equals(itemStack1, itemStack2);
if (itemStack1 != null && itemStack2 != null)
{
if (itemStack1.getItem().getIdFromItem(itemStack1.getItem()) == itemStack2.getItem().getIdFromItem(itemStack2.getItem()))
{
if (itemStack1.getItemDamage() == itemStack2.getItemDamage() || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE)
{
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound())
{
if (itemStack1.getTagCompound().hashCode() == itemStack2.getTagCompound().hashCode())
{
return itemStack2.stackSize >= itemStack1.stackSize;
}
}
else if (!itemStack1.hasTagCompound() && !itemStack2.hasTagCompound())
{
return itemStack2.stackSize >= itemStack1.stackSize;
}
}
}
}
return false;
}
public boolean matches(ItemStack inputStack, ItemStack dustStack)
{
if (OreDictionary.getOreIDs(inputStack).length > 0)
{
if (matches(new WrappedStack(new OreStack(inputStack)), dustStack))
{
return matches(new WrappedStack(new OreStack(inputStack)), dustStack);
}
}
return matches(new WrappedStack(inputStack), dustStack);
}
public boolean matches(WrappedStack inputStack, ItemStack dustStack)
{
return compareStacks(this.inputStack, inputStack) && compareItemStacks(this.dustStack, dustStack);
}
public ItemStack getRecipeOutput()

View file

@ -3,6 +3,7 @@ package com.pahimar.ee3.recipe;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.pahimar.ee3.exchange.WrappedStack;
import com.pahimar.ee3.item.crafting.RecipeAludel;
import com.pahimar.ee3.util.LogHelper;
import java.util.Collection;
@ -73,16 +74,16 @@ public class RecipeRegistry
}
// Add Aludel recipes
// for (RecipeAludel recipeAludel : RecipesAludel.getInstance().getRecipes())
// {
// WrappedStack recipeOutput = new WrappedStack(recipeAludel.getRecipeOutput());
// List<WrappedStack> recipeInputs = recipeAludel.getRecipeInputsAsWrappedStacks();
//
// if (!recipeMap.get(recipeOutput).contains(recipeInputs))
// {
// recipeMap.put(recipeOutput, recipeInputs);
// }
// }
for (RecipeAludel recipeAludel : RecipesAludel.getInstance().getRecipes())
{
WrappedStack recipeOutput = new WrappedStack(recipeAludel.getRecipeOutput());
List<WrappedStack> recipeInputs = recipeAludel.getRecipeInputsAsWrappedStacks();
if (!recipeMap.get(recipeOutput).contains(recipeInputs))
{
recipeMap.put(recipeOutput, recipeInputs);
}
}
}
public Multimap<WrappedStack, List<WrappedStack>> getRecipeMappings()