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.selection; 019 020import baritone.api.utils.BetterBlockPos; 021import net.minecraft.util.EnumFacing; 022 023/** 024 * The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving 025 * the current selection. 026 */ 027public interface ISelectionManager { 028 029 /** 030 * Adds a new selection. The added selection is returned. 031 * 032 * @param selection The new selection to add. 033 */ 034 ISelection addSelection(ISelection selection); 035 036 /** 037 * Adds a new {@link ISelection} constructed from the given block positions. The new selection is returned. 038 * 039 * @param pos1 One corner of the selection 040 * @param pos2 The new corner of the selection 041 */ 042 ISelection addSelection(BetterBlockPos pos1, BetterBlockPos pos2); 043 044 /** 045 * Removes the selection from the current selections. 046 * 047 * @param selection The selection to remove. 048 * @return The removed selection. 049 */ 050 ISelection removeSelection(ISelection selection); 051 052 /** 053 * Removes all selections. 054 * 055 * @return The selections that were removed, sorted from oldest to newest.. 056 */ 057 ISelection[] removeAllSelections(); 058 059 /** 060 * @return The current selections, sorted from oldest to newest. 061 */ 062 ISelection[] getSelections(); 063 064 /** 065 * For anything expecting only one selection, this method is provided. However, to enforce multi-selection support, 066 * this method will only return a selection if there is ONLY one. 067 * 068 * @return The only selection, or null if there isn't only one. 069 */ 070 ISelection getOnlySelection(); 071 072 /** 073 * This method will always return the last selection. ONLY use this if you want to, for example, modify the most 074 * recent selection based on user input. ALWAYS use {@link #getOnlySelection()} or, ideally, 075 * {@link #getSelections()} for retrieving the content of selections. 076 * 077 * @return The last selection, or null if it doesn't exist. 078 */ 079 ISelection getLastSelection(); 080 081 /** 082 * Replaces the specified {@link ISelection} with one expanded in the specified direction by the specified number of 083 * blocks. Returns the new selection. 084 * 085 * @param selection The selection to expand. 086 * @param direction The direction to expand the selection. 087 * @param blocks How many blocks to expand it. 088 * @return The new selection, expanded as specified. 089 */ 090 ISelection expand(ISelection selection, EnumFacing direction, int blocks); 091 092 /** 093 * Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number 094 * of blocks. 095 * <p> 096 * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it 097 * is DOWN, the top of the selection will be shifted down. 098 * 099 * @param selection The selection to contract. 100 * @param direction The direction to contract the selection. 101 * @param blocks How many blocks to contract it. 102 * @return The new selection, contracted as specified. 103 */ 104 ISelection contract(ISelection selection, EnumFacing direction, int blocks); 105 106 /** 107 * Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of 108 * blocks. This moves the whole selection. 109 * 110 * @param selection The selection to shift. 111 * @param direction The direction to shift the selection. 112 * @param blocks How many blocks to shift it. 113 * @return The new selection, shifted as specified. 114 */ 115 ISelection shift(ISelection selection, EnumFacing direction, int blocks); 116}