import * as mc from "@minecraft/server";
import * as utils from "../utils/index";
import { Achievement } from "./achievement";
export class ParkourAchievement extends Achievement {
    constructor() {
        super(...arguments);
        this.SkinIndex = 12;
    }
    onSetup() {
        mc.world.afterEvents.itemUseOn.subscribe(this.onWaterBucketPlace.bind(this));
    }
    onWaterBucketPlace(event) {
        var _a;
        if (event.itemStack.typeId === "minecraft:water_bucket") {
            const player = new utils.SafetyCheckedPlayer(event.source);
            const block = player.dimension.getBlock(player.location);
            if (player.getVelocity().y <= -1 && ((block === null || block === void 0 ? void 0 : block.typeId.includes("water")) || ((_a = block === null || block === void 0 ? void 0 : block.below()) === null || _a === void 0 ? void 0 : _a.typeId.includes("water")))) {
                this.setStatus(player, 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: "item.bucketWater.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: "item.bucketWater.name" },
                            ] } },
                    { text: "\n\n" },
                ] };
        }
    }
}
new ParkourAchievement();
