import { Task } from "../../npc/tasks/task";
import { FindNearbyBlockTask } from "../../npc/tasks/findNearbyBlock";
import { MineVirtualBlockTask } from "./mineVirtualBlock";
const stoneBlocks = [
    { block: 'minecraft:stone', properties: { stone_type: 0 } },
    { block: 'minecraft:cobblestone' },
    { block: 'minecraft:coal_ore' },
    { block: 'minecraft:iron_ore' },
    { block: 'minecraft:copper_ore' },
    { block: 'minecraft:gold_ore' },
    { block: 'minecraft:lapis_ore' },
    { block: 'minecraft:redstone_ore' },
    { block: 'minecraft:lit_redstone_ore' },
    { block: 'minecraft:emerald_ore' },
    { block: 'minecraft:diamond_ore' },
];
const andesiteBlocks = [
    { block: 'minecraft:andesite', properties: { stone_type: 5 } },
];
const dioriteBlocks = [
    { block: 'minecraft:stone', properties: { stone_type: 3 } },
];
const graniteBlocks = [
    { block: 'minecraft:stone', properties: { stone_type: 1 } },
];
const deepBlocks = [
    { block: 'minecraft:tuff' },
    { block: 'minecraft:deepslate' },
    { block: 'minecraft:deepslate_coal_ore' },
    { block: 'minecraft:deepslate_iron_ore' },
    { block: 'minecraft:deepslate_copper_ore' },
    { block: 'minecraft:deepslate_gold_ore' },
    { block: 'minecraft:deepslate_lapis_ore' },
    { block: 'minecraft:deepslate_redstone_ore' },
    { block: 'minecraft:deepslate_emerald_ore' },
    { block: 'minecraft:deepslate_diamond_ore' },
];
const netherBlocks = [
    { block: 'minecraft:netherrack' },
];
const MineDefaults = {
    virtualBlockTypeId: "ldz_crcomp:craftee_block",
};
export class GoMiningTask extends Task {
    async performTask() {
        const overworldFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: stoneBlocks }, this).start();
        if (overworldFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "stone" }, MineDefaults), { locationData: overworldFoundBlock.data }), this).start();
        }
        const andesiteFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: andesiteBlocks }, this).start();
        if (andesiteFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "andesite" }, MineDefaults), { locationData: andesiteFoundBlock.data }), this).start();
        }
        const dioriteFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: dioriteBlocks }, this).start();
        if (dioriteFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "diorite" }, MineDefaults), { locationData: dioriteFoundBlock.data }), this).start();
        }
        const graniteFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: graniteBlocks }, this).start();
        if (graniteFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "granite" }, MineDefaults), { locationData: graniteFoundBlock.data }), this).start();
        }
        const deepFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: deepBlocks }, this).start();
        if (deepFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "deepslate" }, MineDefaults), { locationData: deepFoundBlock.data }), this).start();
        }
        const netherFoundBlock = await new FindNearbyBlockTask(this.npc, { blocks: netherBlocks }, this).start();
        if (netherFoundBlock.outcome === "succeeded") {
            this.npc.broadcastEvent("mine");
            return await new MineVirtualBlockTask(this.npc, Object.assign(Object.assign({ blockType: "netherrack" }, MineDefaults), { locationData: netherFoundBlock.data }), this).start();
        }
        this.npc.broadcastEvent("no_mine");
        return { outcome: "failed" };
    }
    async cleanupTask() {
    }
}
