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.schematic.ISchematic;
021import net.minecraft.client.Minecraft;
022import net.minecraft.core.BlockPos;
023import net.minecraft.core.Vec3i;
024import net.minecraft.world.level.block.state.BlockState;
025import java.io.File;
026import java.util.List;
027import java.util.Optional;
028
029/**
030 * @author Brady
031 * @since 1/15/2019
032 */
033public interface IBuilderProcess extends IBaritoneProcess {
034
035    /**
036     * Requests a build for the specified schematic, labeled as specified, with the specified origin.
037     *
038     * @param name      A user-friendly name for the schematic
039     * @param schematic The object representation of the schematic
040     * @param origin    The origin position of the schematic being built
041     */
042    void build(String name, ISchematic schematic, Vec3i origin);
043
044    /**
045     * Requests a build for the specified schematic, labeled as specified, with the specified origin.
046     *
047     * @param name      A user-friendly name for the schematic
048     * @param schematic The file path of the schematic
049     * @param origin    The origin position of the schematic being built
050     * @return Whether or not the schematic was able to load from file
051     */
052    boolean build(String name, File schematic, Vec3i origin);
053
054    @Deprecated
055    default boolean build(String schematicFile, BlockPos origin) {
056        File file = new File(new File(Minecraft.getInstance().gameDirectory, "schematics"), schematicFile);
057        return build(schematicFile, file, origin);
058    }
059
060    void buildOpenSchematic();
061
062    void buildOpenLitematic(int i);
063
064    void pause();
065
066    boolean isPaused();
067
068    void resume();
069
070    void clearArea(BlockPos corner1, BlockPos corner2);
071
072    /**
073     * @return A list of block states that are estimated to be placeable by this builder process. You can use this in
074     * schematics, for example, to pick a state that the builder process will be happy with, because any variation will
075     * cause it to give up. This is updated every tick, but only while the builder process is active.
076     */
077    List<BlockState> getApproxPlaceable();
078    /**
079     * Returns the lower bound of the current mining layer if mineInLayers is true.
080     * If mineInLayers is false, this will return an empty optional.
081     * @return The lower bound of the current mining layer
082     */
083    Optional<Integer> getMinLayer();
084
085    /**
086     * Returns the upper bound of the current mining layer if mineInLayers is true.
087     * If mineInLayers is false, this will return an empty optional.
088     * @return The upper bound of the current mining layer
089     */
090    Optional<Integer> getMaxLayer();
091}