Skip to content

Commit

Permalink
Bugfix: It was possible to add more than <maxamount> to redstone/lapi…
Browse files Browse the repository at this point in the history
…s/... modifiers if they were exactly at a lvlup threshold
  • Loading branch information
bonii-xx committed Jul 30, 2014
1 parent f6877b5 commit 527934d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModAntiSpider.java
Expand Up @@ -24,6 +24,9 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;

if(matchingAmount(input) > max)
return false;

int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModAttack.java
Expand Up @@ -45,6 +45,9 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!validType(toolItem))
return false;

if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModBlaze.java
Expand Up @@ -28,6 +28,9 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!validType(toolItem))
return false;

if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModLapis.java
Expand Up @@ -33,6 +33,9 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!validType(toolItem))
return false;

if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");

if (tags.getBoolean("Silk Touch"))
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModPiston.java
Expand Up @@ -29,6 +29,9 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!validType(toolItem))
return false;

if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/tconstruct/modifiers/tools/ModRedstone.java
Expand Up @@ -28,14 +28,17 @@ protected boolean canModify (ItemStack tool, ItemStack[] input)
if (!validType(toolItem))
return false;

if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;

int keyPair[] = tags.getIntArray(key);

if (keyPair[0] + matchingAmount(input) <= keyPair[1])
return true;

else if (keyPair[0] == keyPair[1])
return tags.getInteger("Modifiers") > 0;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/modifiers/tools/ModSmite.java
Expand Up @@ -19,6 +19,9 @@ public ModSmite(String type, int effect, ItemStack[] items, int[] values)
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
if(matchingAmount(input) > max)
return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
Expand Down

0 comments on commit 527934d

Please sign in to comment.