- Denizen Version
- 1.2.8
I needed a way to turn an id (starting at 1 and going into the thousands, tens of thousands, so on) into coordinates that spiral around a point in a grid. I didn't want to do it with loops because as more ids get consumed, the run time to find the next coordinate would continue to increase and increase. So after scouring the internet I've found a formula to do it in constant time, no loops, and thought I'd share here after converting it into a proc. It doesn't matter if the id is 1 or 1000000000, this calculates it super quick.
The input is an id value and the output is a map of x and z coords for where that id would lie on the spiral grid. You can multiply the outputs to space the coords out however far you like.
Provided is an example task that spawns in a grid pattern of blocks over time, spaced out.
The input is an id value and the output is a map of x and z coords for where that id would lie on the spiral grid. You can multiply the outputs to space the coords out however far you like.
Provided is an example task that spawns in a grid pattern of blocks over time, spaced out.