Class BlockScan

java.lang.Object
dev.myriadclient.api.world.BlockScan

public final class BlockScan extends Object
Fast block searches over a chunk. Each 16×16×16 section keeps a palette of the states it holds, so a section that can't contain a match is skipped without reading a single block: looking for obsidian or ores usually touches a handful of sections instead of the ~100,000 blocks of a full chunk. Pair it with ChunkCache, which calls you once per chunk as chunks load and change.
BlockScan.forEach(chunk, state -> state.is(Blocks.ANCIENT_DEBRIS), (pos, state) -> found.add(pos.immutable()));
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Receives each match.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(net.minecraft.world.level.chunk.LevelChunk chunk, Predicate<net.minecraft.world.level.block.state.BlockState> filter)
    True if any block in chunk matches, checking palettes first and stopping at the first match.
    static void
    forEach(net.minecraft.world.level.chunk.LevelChunk chunk, Predicate<net.minecraft.world.level.block.state.BlockState> filter, BlockScan.Visitor visitor)
    Visits every block in chunk whose state matches filter, bottom to top.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • forEach

      public static void forEach(net.minecraft.world.level.chunk.LevelChunk chunk, Predicate<net.minecraft.world.level.block.state.BlockState> filter, BlockScan.Visitor visitor)
      Visits every block in chunk whose state matches filter, bottom to top. A filter that matches air reads every all-air section too, so keep it to the blocks you want. It reads only the chunk, so it suits a ChunkCache.async() compute.
    • contains

      public static boolean contains(net.minecraft.world.level.chunk.LevelChunk chunk, Predicate<net.minecraft.world.level.block.state.BlockState> filter)
      True if any block in chunk matches, checking palettes first and stopping at the first match.