How to select a region

I was wondering if it was possible to select just a “region” of a world.
For example just 100 blocks around a player.
Can you give me an example of code?

Thanks for your help!

You’re looking for this method.

1 Like


While I’m here, do you know how I could check for a list of biomes in this extend and get the location of one? I’m stuck at this part too :confused:

Extent extends BiomeVolume, so you can use all of the BiomeVolume methods in it.

1 Like

I’m a learning to code and looking to create a “tp to biome” plugin.
Is there a way to list all the biomes in Extent and get the location of a desired one?

Not directly. You will have to go through all of the coordinates in the Extent and get the biome at each location.

When you say all the coordinates, is it every combination of (x,y) or can you somehow reduce the areas by knowing groups of same biome?

Every combination of x and z. y is currently ignored, but it’s there in case Mojang adds 3D biomes in the future. You can speed it up by not checking every coordinate, but there are no guarantees. Keep in mind that rivers are a separate biome, so you need to make sure your code can find them.

Ok! Thank you :relaxed:
One last thing, is there a way to prevent your code from making the server “hang”. Something to say “Hey code, execute yourself but please let the server do his job meanwhile”?

You can use Task.builder().asynchronous().execute(() -> { /* code */}).submit(/* your @Plugin object */).

1 Like

Thank you very much for all your help Sirs! :heart:

Note that a good chunk of the API is unusable in asynchronous mode.

Also, to go over every block in the chunk, you can resize it to only 1 block tall, call getBlockWorker to get the worker, and then call reduce, where T is List<BiomeType>, the identity is an empty list, the merge calls addAll, and the reducer adds the BiomeType to the list.