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; 022import net.minecraft.util.math.AxisAlignedBB; 023import net.minecraft.util.math.Vec3i; 024 025/** 026 * A selection is an immutable object representing the current selection. The selection is commonly used for certain 027 * types of build commands, however it can be used for anything. 028 */ 029public interface ISelection { 030 031 /** 032 * @return The first corner of this selection. This is meant to preserve the user's original first corner. 033 */ 034 BetterBlockPos pos1(); 035 036 /** 037 * @return The second corner of this selection. This is meant to preserve the user's original second corner. 038 */ 039 BetterBlockPos pos2(); 040 041 /** 042 * @return The {@link BetterBlockPos} with the lowest x, y, and z position in the selection. 043 */ 044 BetterBlockPos min(); 045 046 /** 047 * @return The opposite corner from the {@link #min()}. 048 */ 049 BetterBlockPos max(); 050 051 /** 052 * @return The size of this ISelection. 053 */ 054 Vec3i size(); 055 056 /** 057 * @return An {@link AxisAlignedBB} encompassing all blocks in this selection. 058 */ 059 AxisAlignedBB aabb(); 060 061 /** 062 * Returns a new {@link ISelection} expanded in the specified direction by the specified number of blocks. 063 * 064 * @param direction The direction to expand the selection. 065 * @param blocks How many blocks to expand it. 066 * @return A new selection, expanded as specified. 067 */ 068 ISelection expand(EnumFacing direction, int blocks); 069 070 /** 071 * Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks. 072 * <p> 073 * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it 074 * is DOWN, the top of the selection will be shifted down. 075 * 076 * @param direction The direction to contract the selection. 077 * @param blocks How many blocks to contract it. 078 * @return A new selection, contracted as specified. 079 */ 080 ISelection contract(EnumFacing direction, int blocks); 081 082 /** 083 * Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves 084 * the whole selection. 085 * 086 * @param direction The direction to shift the selection. 087 * @param blocks How many blocks to shift it. 088 * @return A new selection, shifted as specified. 089 */ 090 ISelection shift(EnumFacing direction, int blocks); 091}