Skip to content

Commit

Permalink
Fix filter amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Dec 12, 2013
1 parent 30e51d3 commit 50fdf1b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
11 changes: 9 additions & 2 deletions src/main/java/tconstruct/library/tools/ToolMod.java
Expand Up @@ -211,8 +211,15 @@ public boolean validType (ToolCore tool)
{
return true;
}

protected boolean areItemStacksEquivalent (ItemStack stack1, ItemStack stack2)

public boolean areItemsEquivalent (ItemStack stack1, ItemStack stack2)
{
if (stack1.itemID != stack2.itemID)
return false;
return ItemStack.areItemStackTagsEqual(stack1, stack2);
}

public boolean areItemStacksEquivalent (ItemStack stack1, ItemStack stack2)
{
if (stack1.itemID != stack2.itemID)
return false;
Expand Down
31 changes: 17 additions & 14 deletions src/main/java/tconstruct/modifiers/tools/ToolModTypeFilter.java
Expand Up @@ -44,11 +44,9 @@ public boolean matches (ItemStack[] input, ItemStack tool)
for (Object check : stacks)
{
ItemStack stack = (ItemStack) check;
System.out.println("First stack: "+stack);
System.out.println("Second stack: "+inputStack);
if (stack.getItemDamage() == Short.MAX_VALUE)
{
if (inputStack.isItemEqual(stack))
if (this.areItemsEquivalent(inputStack, stack))
match = true;
}
else
Expand All @@ -58,40 +56,45 @@ public boolean matches (ItemStack[] input, ItemStack tool)
}
}
if (!match)
{
System.out.println("Not a match");
return false;
}

minimumMatch = true;
}
System.out.println("Object: " + minimumMatch);
return minimumMatch;
}

public int matchingAmount (ItemStack[] input)
{
int amount = 0;
for (ItemStack i : input)
for (ItemStack inputStack : input)
{
if (i == null)
if (inputStack == null)
continue;
else
{
for (int iter = 0; iter < stacks.size(); iter++)
{
ItemStack check = (ItemStack) stacks.get(iter);
if (ItemStack.areItemStacksEqual(i, check))
amount += increase.get(iter);
ItemStack stack = (ItemStack) stacks.get(iter);
if (stack.getItemDamage() == Short.MAX_VALUE)
{
if (this.areItemsEquivalent(inputStack, stack))
amount += increase.get(iter);
}
else
{
if (this.areItemStacksEquivalent(inputStack, stack))
amount += increase.get(iter);
}
}
}
}
return amount;
}

/** Adds a new itemstack to the list of increases
/** Adds a new itemstack to the list for increases
*
* @param stack ItemStack to compare against
* @param increase Amount to increase
* @param amount Amount to increase
*/
public void addStackToMatchList (ItemStack stack, int amount)
{
Expand Down

0 comments on commit 50fdf1b

Please sign in to comment.