#How to get Chunks

1 messages · Page 1 of 1 (latest)

agile beacon
#

its possible to get chunks in the world with scripting? I want to do a custom world gen and place structures per chunks gen. If not, do you know what its the formula to get chunks in world gen?

agile beacon
unique aspen
#

The world coordinates.

agile beacon
#

But that alone doesn't guarantee that it's the center of a chunk, does it?

unique aspen
#

It's simple math, each chunk is 16x16 on the x/z axis. Get a random coordinate, and calcukate the nearest chunk border.

agile beacon
#
const chunkX = Math.floor(pos.x / 16);
const chunkZ = Math.floor(pos.z / 16);

const cornerX = chunkX * 16;
const cornerZ = chunkZ * 16;```
this should work, right?
distant jewel
#

I had this code

#

just shared it if you need

agile beacon
distant jewel