import { Task } from "../../npc/tasks/task";
import { FindNearbyBlockTask } from "../../npc/tasks/findNearbyBlock";
import { MineVirtualBlockTask } from "./mineVirtualBlock";
const MineDefaults = {
    virtualBlockTypeId: "ldz_crcomp:craftee_block",
};
export class GoLoggingTask extends Task {
    async performTask() {
        const grassFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: [{ block: "minecraft:grass" }] }, this).start();
        if (grassFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("chop");
            const treeType = this.npc.Entity.getProperty("ldz_crcomp:tree_type");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: treeType }, MineDefaults), { locationData: grassFoundBlock.data }), this).start();
        }
        const crimsonFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: [{ block: "minecraft:crimson_nylium" }] }, this).start();
        if (crimsonFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("chop");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "crimson_log" }, MineDefaults), { locationData: crimsonFoundBlock.data }), this).start();
        }
        const warpedFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: [{ block: "minecraft:warped_nylium" }] }, this).start();
        if (warpedFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("chop");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "warped_stem" }, MineDefaults), { locationData: warpedFoundBlock.data }), this).start();
        }
        this.npc.broadcastEvent("no_log");
        return { outcome: "failed" };
    }
    async cleanupTask() {
    }
}
