001/*
002 * This file is part of Baritone.
003 *
004 * Baritone is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU Lesser General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * Baritone is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU Lesser General Public License for more details.
013 *
014 * You should have received a copy of the GNU Lesser General Public License
015 * along with Baritone.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package baritone.api.process;
019
020import baritone.api.utils.BlockOptionalMeta;
021import baritone.api.utils.BlockOptionalMetaLookup;
022import java.util.stream.Stream;
023import net.minecraft.world.level.block.Block;
024
025/**
026 * @author Brady
027 * @since 9/23/2018
028 */
029public interface IMineProcess extends IBaritoneProcess {
030
031    /**
032     * Begin to search for and mine the specified blocks until
033     * the number of specified items to get from the blocks that
034     * are mined.
035     *
036     * @param quantity The total number of items to get
037     * @param blocks   The blocks to mine
038     */
039    void mineByName(int quantity, String... blocks);
040
041    /**
042     * Begin to search for and mine the specified blocks until
043     * the number of specified items to get from the blocks that
044     * are mined. This is based on the first target block to mine.
045     *
046     * @param quantity The number of items to get from blocks mined
047     * @param filter   The blocks to mine
048     */
049    void mine(int quantity, BlockOptionalMetaLookup filter);
050
051    /**
052     * Begin to search for and mine the specified blocks.
053     *
054     * @param filter The blocks to mine
055     */
056    default void mine(BlockOptionalMetaLookup filter) {
057        mine(0, filter);
058    }
059
060    /**
061     * Begin to search for and mine the specified blocks.
062     *
063     * @param blocks The blocks to mine
064     */
065    default void mineByName(String... blocks) {
066        mineByName(0, blocks);
067    }
068
069    /**
070     * Begin to search for and mine the specified blocks.
071     *
072     * @param boms The blocks to mine
073     */
074    default void mine(int quantity, BlockOptionalMeta... boms) {
075        mine(quantity, new BlockOptionalMetaLookup(boms));
076    }
077
078    /**
079     * Begin to search for and mine the specified blocks.
080     *
081     * @param boms The blocks to mine
082     */
083    default void mine(BlockOptionalMeta... boms) {
084        mine(0, boms);
085    }
086
087    /**
088     * Begin to search for and mine the specified blocks.
089     *
090     * @param quantity The total number of items to get
091     * @param blocks   The blocks to mine
092     */
093    default void mine(int quantity, Block... blocks) {
094        mine(quantity, new BlockOptionalMetaLookup(
095                Stream.of(blocks)
096                        .map(BlockOptionalMeta::new)
097                        .toArray(BlockOptionalMeta[]::new)
098        ));
099    }
100
101    /**
102     * Begin to search for and mine the specified blocks.
103     *
104     * @param blocks The blocks to mine
105     */
106    default void mine(Block... blocks) {
107        mine(0, blocks);
108    }
109
110    /**
111     * Cancels the current mining task
112     */
113    default void cancel() {
114        onLostControl();
115    }
116}