import * as mc from "@minecraft/server";
import * as utils from "../utils/index";
import { Achievement } from "./achievement";
export class ArcheologistAchievement extends Achievement {
    constructor() {
        super(...arguments);
        this.SkinIndex = 1;
    }
    onSetup() {
        mc.world.afterEvents.itemUseOn.subscribe(this.onBrush.bind(this));
    }
    onBrush(event) {
        if (event.itemStack.typeId === "minecraft:brush") {
            if (event.block.typeId === "minecraft:suspicious_sand" || event.block.typeId === "minecraft:suspicious_gravel") {
                utils.waitForEvent(5, () => {
                    const block = event.block.dimension.getBlock(event.block.location);
                    if (block.typeId === "minecraft:sand" || block.typeId === "minecraft:gravel") {
                        this.setStatus(new utils.SafetyCheckedPlayer(event.source), true);
                    }
                });
            }
        }
    }
    getStatusText(player) {
        if (this.getStatus(player)) {
            return { rawtext: [
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.title.completed` },
                    { text: "\n" },
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.status.completed`, with: { rawtext: [
                                { translate: "tile.suspicious_sand.name" },
                                { translate: "tile.suspicious_gravel.name" },
                            ] } },
                    { text: "\n\n" },
                ] };
        }
        else {
            return { rawtext: [
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.title.in_progress` },
                    { text: "\n" },
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.status.in_progress`, with: { rawtext: [
                                { translate: "tile.suspicious_sand.name" },
                                { translate: "tile.suspicious_gravel.name" },
                            ] } },
                    { text: "\n\n" },
                ] };
        }
    }
}
new ArcheologistAchievement();
