diff --git a/src/api/java/baritone/api/IBaritoneProvider.java b/src/api/java/baritone/api/IBaritoneProvider.java index aa20979b..88c4adff 100644 --- a/src/api/java/baritone/api/IBaritoneProvider.java +++ b/src/api/java/baritone/api/IBaritoneProvider.java @@ -19,6 +19,7 @@ package baritone.api; import baritone.api.behavior.*; import baritone.api.cache.IWorldProvider; +import baritone.api.cache.IWorldScanner; import baritone.api.event.listener.IGameEventListener; /** @@ -69,6 +70,13 @@ public interface IBaritoneProvider { */ IWorldProvider getWorldProvider(); + /** + * @see IWorldScanner + * + * @return The {@link IWorldScanner} instance + */ + IWorldScanner getWorldScanner(); + /** * Registers a {@link IGameEventListener} with Baritone's "event bus". * diff --git a/src/api/java/baritone/api/cache/IWorldScanner.java b/src/api/java/baritone/api/cache/IWorldScanner.java new file mode 100644 index 00000000..c35757ef --- /dev/null +++ b/src/api/java/baritone/api/cache/IWorldScanner.java @@ -0,0 +1,42 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.api.cache; + +import net.minecraft.block.Block; +import net.minecraft.util.math.BlockPos; + +import java.util.List; + +/** + * @author Brady + * @since 10/6/2018 + */ +public interface IWorldScanner { + + /** + * Scans the world, up to the specified max chunk radius, for the specified blocks. + * + * @param blocks The blocks to scan for + * @param max The maximum number of blocks to scan before cutoff + * @param yLevelThreshold If a block is found within this Y level, the current result will be + * returned, if the value is negative, then this condition doesn't apply. + * @param maxSearchRadius The maximum chunk search radius + * @return The matching block positions + */ + List scanLoadedChunks(List blocks, int max, int yLevelThreshold, int maxSearchRadius); +} diff --git a/src/main/java/baritone/BaritoneProvider.java b/src/main/java/baritone/BaritoneProvider.java index eb6bf27a..d9dfe624 100644 --- a/src/main/java/baritone/BaritoneProvider.java +++ b/src/main/java/baritone/BaritoneProvider.java @@ -20,9 +20,11 @@ package baritone; import baritone.api.IBaritoneProvider; import baritone.api.behavior.*; import baritone.api.cache.IWorldProvider; +import baritone.api.cache.IWorldScanner; import baritone.api.event.listener.IGameEventListener; import baritone.behavior.*; import baritone.cache.WorldProvider; +import baritone.cache.WorldScanner; /** * @author Brady @@ -60,6 +62,11 @@ public final class BaritoneProvider implements IBaritoneProvider { return WorldProvider.INSTANCE; } + @Override + public IWorldScanner getWorldScanner() { + return WorldScanner.INSTANCE; + } + @Override public void registerEventListener(IGameEventListener listener) { Baritone.INSTANCE.registerEventListener(listener); diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index d6b466ef..a0d905c6 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -17,6 +17,7 @@ package baritone.cache; +import baritone.api.cache.IWorldScanner; import baritone.utils.Helper; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -29,19 +30,11 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import java.util.LinkedList; import java.util.List; -public enum WorldScanner implements Helper { +public enum WorldScanner implements IWorldScanner, Helper { + INSTANCE; - /** - * Scans the world, up to your render distance, for the specified blocks. - * - * @param blocks The blocks to scan for - * @param max The maximum number of blocks to scan before cutoff - * @param yLevelThreshold If a block is found within this Y level, the current result will be - * returned, if the value is negative, then this condition doesn't apply. - * @param maxSearchRadius The maximum chunk search radius - * @return The matching block positions - */ + @Override public List scanLoadedChunks(List blocks, int max, int yLevelThreshold, int maxSearchRadius) { if (blocks.contains(null)) { throw new IllegalStateException("Invalid block name should have been caught earlier: " + blocks.toString());