Пример #1
0
  public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata) {
    if (block.blockMaterial.isToolNotRequired()) {
      return true;
    }

    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null) {
      return player.canHarvestBlock(block);
    }

    List info = toolClasses.get(stack.getItem());
    if (info == null) {
      return player.canHarvestBlock(block);
    }

    Object[] tmp = info.toArray();
    String toolClass = (String) tmp[0];
    int harvestLevel = (Integer) tmp[1];

    Integer blockHarvestLevel = toolHarvestLevels.get(Arrays.asList(block, metadata, toolClass));
    if (blockHarvestLevel == null) {
      return player.canHarvestBlock(block);
    }

    if (blockHarvestLevel > harvestLevel) {
      return false;
    }
    return true;
  }
Пример #2
0
  public static boolean canToolHarvestBlock(Block block, int metadata, ItemStack stack) {
    if (stack == null) return false;
    List info = toolClasses.get(stack.getItem());
    if (info == null) return false;

    Object[] tmp = info.toArray();
    String toolClass = (String) tmp[0];
    int harvestLevel = (Integer) tmp[1];

    Integer blockHarvestLevel = toolHarvestLevels.get(Arrays.asList(block, metadata, toolClass));
    return !(blockHarvestLevel == null || blockHarvestLevel > harvestLevel);
  }
Пример #3
0
 public static boolean isToolEffective(ItemStack stack, Block block, int metadata) {
   List toolClass = toolClasses.get(stack.getItem());
   return toolClass != null
       && toolEffectiveness.contains(Arrays.asList(block, metadata, toolClass.get(0)));
 }