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.cache; 019 020import baritone.api.utils.BlockOptionalMetaLookup; 021import baritone.api.utils.IPlayerContext; 022import java.util.List; 023import net.minecraft.core.BlockPos; 024import net.minecraft.world.level.ChunkPos; 025import net.minecraft.world.level.block.Block; 026 027/** 028 * @author Brady 029 * @since 10/6/2018 030 */ 031public interface IWorldScanner { 032 033 /** 034 * Scans the world, up to the specified max chunk radius, for the specified blocks. 035 * 036 * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon 037 * @param filter The blocks to scan for 038 * @param max The maximum number of blocks to scan before cutoff 039 * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value 040 * is negative, then this condition doesn't apply. 041 * @param maxSearchRadius The maximum chunk search radius 042 * @return The matching block positions 043 */ 044 List<BlockPos> scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius); 045 046 default List<BlockPos> scanChunkRadius(IPlayerContext ctx, List<Block> filter, int max, int yLevelThreshold, int maxSearchRadius) { 047 return scanChunkRadius(ctx, new BlockOptionalMetaLookup(filter.toArray(new Block[0])), max, yLevelThreshold, maxSearchRadius); 048 } 049 050 /** 051 * Scans a single chunk for the specified blocks. 052 * 053 * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon 054 * @param filter The blocks to scan for 055 * @param pos The position of the target chunk 056 * @param max The maximum number of blocks to scan before cutoff 057 * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value 058 * is negative, then this condition doesn't apply. 059 * @return The matching block positions 060 */ 061 List<BlockPos> scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filter, ChunkPos pos, int max, int yLevelThreshold); 062 063 /** 064 * Scans a single chunk for the specified blocks. 065 * 066 * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon 067 * @param blocks The blocks to scan for 068 * @param pos The position of the target chunk 069 * @param max The maximum number of blocks to scan before cutoff 070 * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value 071 * is negative, then this condition doesn't apply. 072 * @return The matching block positions 073 */ 074 default List<BlockPos> scanChunk(IPlayerContext ctx, List<Block> blocks, ChunkPos pos, int max, int yLevelThreshold) { 075 return scanChunk(ctx, new BlockOptionalMetaLookup(blocks), pos, max, yLevelThreshold); 076 } 077 078 /** 079 * Overload of {@link #repack(IPlayerContext, int)} where the value of the {@code range} parameter is {@code 40}. 080 * 081 * @param ctx The player, describing the origin 082 * @return The amount of chunks successfully queued for repacking 083 */ 084 int repack(IPlayerContext ctx); 085 086 /** 087 * Queues the chunks in a square formation around the specified player, using the specified 088 * range, which represents 1/2 the square's dimensions, where the player is in the center. 089 * 090 * @param ctx The player, describing the origin 091 * @param range The range to repack 092 * @return The amount of chunks successfully queued for repacking 093 */ 094 int repack(IPlayerContext ctx, int range); 095}