Edits enable use of EntityPlayer.canHarvestBlock (for PlayerAPI) when the ToolClass has no rules for the block.

This commit is contained in:
ShetiPhian 2012-04-16 23:01:40 -03:00
parent 36c7a35db9
commit 8ffd66f27f

View file

@ -431,13 +431,13 @@ public class ForgeHooks
ItemStack stack = player.inventory.getCurrentItem(); ItemStack stack = player.inventory.getCurrentItem();
if (stack == null) if (stack == null)
{ {
return false; return player.canHarvestBlock(block);
} }
List info = (List)toolClasses.get(stack.itemID); List info = (List)toolClasses.get(stack.itemID);
if (info == null) if (info == null)
{ {
return stack.canHarvestBlock(block); return player.canHarvestBlock(block);
} }
Object[] tmp = info.toArray(); Object[] tmp = info.toArray();
String toolClass = (String)tmp[0]; String toolClass = (String)tmp[0];
@ -446,7 +446,7 @@ public class ForgeHooks
Integer blockHarvestLevel = (Integer)toolHarvestLevels.get(Arrays.asList(block.blockID, metadata, toolClass)); Integer blockHarvestLevel = (Integer)toolHarvestLevels.get(Arrays.asList(block.blockID, metadata, toolClass));
if (blockHarvestLevel == null) if (blockHarvestLevel == null)
{ {
return stack.canHarvestBlock(block); return player.canHarvestBlock(block);
} }
if (blockHarvestLevel > harvestLevel) if (blockHarvestLevel > harvestLevel)
{ {