import { Task } from "../../npc/tasks/task";
import { FindNearbyBlockTask } from "../../npc/tasks/findNearbyBlock";
import { MineVirtualBlockTask } from "./mineVirtualBlock";
const dirtBlocks = [
    { block: "minecraft:grass" },
    { block: "minecraft:dirt" },
    { block: "minecraft:gravel" },
];
const sandBlocks = [
    { block: "minecraft:sand" },
];
const soulBlocks = [
    { block: "minecraft:soul_sand" },
    { block: "minecraft:soul_soil" },
];
const MineDefaults = {
    virtualBlockTypeId: "ldz_crcomp:craftee_block",
};
export class GoDiggingTask extends Task {
    async performTask() {
        const dirtFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: dirtBlocks }, this).start();
        if (dirtFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("dig");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "dirt" }, MineDefaults), { locationData: dirtFoundBlock.data }), this).start();
        }
        const sandFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: sandBlocks }, this).start();
        if (sandFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("dig");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "sand" }, MineDefaults), { locationData: sandFoundBlock.data }), this).start();
        }
        const soulFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: soulBlocks }, this).start();
        if (soulFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("dig");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "soul_sand" }, MineDefaults), { locationData: soulFoundBlock.data }), this).start();
        }
        this.npc.broadcastEvent("no_dig");
        return { outcome: "failed" };
    }
    async cleanupTask() {
    }
}
