<commit_before>mf.include("player_tracker.js");
mf.include("chat_commands.js");
mf.include("items.js");
mf.include("block_finder.js");

(function() {
    function find(username, args, responder_func) {
        var player = player_tracker.entityForPlayer(username);
        if (player === undefined) {
            responder_func("I couldn't even find YOU, " + username + "!");
            return;
        }
        var itemName = args.join(" ");
        var item = items.findBlockTypeUnambiguously(itemName,responder_func);
        if (item === undefined) {
            return;
        }
        var type = item.id;
        responder_func("Trying to find " + items.nameForId(type) + " closest to " + username + "...");
        var position = player.position;
        var coordinates = block_finder.findNearest(position,type).shift();
        if (coordinates === undefined) {
            responder_func("I couldn't find any " + itemName + ".");
            return;
        }

        var relativeCoordinates = coordinates.minus(position);

        eastWest = relativeCoordinates.x < 0 ? "West" : "East";
        northSouth = relativeCoordinates.y < 0 ? "South" : "North";
        upDown = relativeCoordinates.z < 0 ? "Down" : "Up";

        responder_func("I found some " + items.nameForId(type) + "! Go " + eastWest + " " + Math.abs(relativeCoordinates.x) + " blocks, " + northSouth + " " + Math.abs(relativeCoordinates.y) + " blocks, and " + upDown + " " + Math.abs(relativeCoordinates.z) + " blocks."); 
        return coordinates;
    }
    chat_commands.registerCommand("find", find, 1, Infinity);
})();
<commit_msg>finder.js looks toward the goal when he finds it<commit_after>mf.include("player_tracker.js");
mf.include("chat_commands.js");
mf.include("items.js");
mf.include("block_finder.js");

(function() {
    function find(username, args, responder_func) {
        var player = player_tracker.entityForPlayer(username);
        if (player === undefined) {
            responder_func("I couldn't even find YOU, " + username + "!");
            return;
        }
        var itemName = args.join(" ");
        var item = items.findBlockTypeUnambiguously(itemName,responder_func);
        if (item === undefined) {
            return;
        }
        var type = item.id;
        responder_func("Trying to find " + items.nameForId(type) + " closest to " + username + "...");
        var position = player.position;
        var coordinates = block_finder.findNearest(position,type).shift();
        if (coordinates === undefined) {
            responder_func("I couldn't find any " + itemName + ".");
            return;
        }

        var relativeCoordinates = coordinates.minus(position);

        eastWest = relativeCoordinates.x < 0 ? "West" : "East";
        northSouth = relativeCoordinates.y < 0 ? "South" : "North";
        upDown = relativeCoordinates.z < 0 ? "Down" : "Up";

        responder_func("I found some " + items.nameForId(type) + "! Go " + eastWest + " " + Math.abs(relativeCoordinates.x) + " blocks, " + northSouth + " " + Math.abs(relativeCoordinates.y) + " blocks, and " + upDown + " " + Math.abs(relativeCoordinates.z) + " blocks."); 
        mf.lookAt(coordinates);
        return coordinates;
    }
    chat_commands.registerCommand("find", find, 1, Infinity);
})();

{'fraction_non_alphanumeric': 0.14795763993948563, 'fraction_numerical': 0.002420574886535552, 'mean_word_length': 2.7146067415730335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4357279', 'n_tokens_mistral': 988, 'n_tokens_neox': 962, 'n_words': 201}