1.15.2 Generating Very Large Structures

Discussion in 'Spigot Plugin Development' started by TrollyLoki, Jun 11, 2020.

  1. Say I want to generate a large structure based around a single point in the world. The points where these structures will be placed is randomized along with world generation. My difficulty is that the structures can be much bigger than the render distance, so if I randomly choose a point during chunk generation the structure may suddenly appear in already generated chunks. A way around this is to check chunks around each generated chunk up to the maximum size of the structure. The problem with that is that it takes way too long to check all those chunks for a very large structure.

    How can I optimize this system to choose points ahead of chunk generation but without looping through hundreds of chunks?
    Any ideas are appreciated.
     
  2. When placing or setting the blocks you should generate the chunk. Something like this: https://www.spigotmc.org/threads/ch...nks-how-do-i-render-chunks-automaticly.57706/ will help you automagically load a chunk w/o it needing to be in "render distance" then you can safely know that the chunk is loaded.

    Edit you can also use this: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Chunk.html#setForceLoaded-boolean-