Skip to content

Using the WorldIteratorAPI

PukPukov edited this page Jul 23, 2022 · 1 revision

WorldIteratorAPI is an API for iterating through the game world. Useful, for example, for scanning the terrain.

Usage

The WorldIteratorAPI uses the coordinate system from ScalarContainers. That is, to get the coordinate of the point at the location, you will need to do something like DiscretePosition#getCoordinate(Axis.Y);. In short, ScalarContainers is a library for unified work with a multi-dimensional discrete space, for example 2D or 4D.

To iterate around the world, you can do this:

    World world = Bukkit.getWorld("world");
    new WorldIterator(
            world,
            world.getChunkAt(-100, -100),
            world.getChunkAt(100, 100)
    ).iterator().forEachRemaining(chunk -> {
        // doing something with every chunk
    });
Clone this wiki locally