on chunk generation?

Discussion in 'Plugin Development' started by Megolas, Oct 11, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Megolas

    Hello,
    Is there an event that runs upon the finishing of generating a chunk? I know about ChunkPopulate event, but I'm not sure exactly when its ran...

    Thanks
     
  2. Offline

    slam5000

    try this:
    @EventHandler
    public void chunkGenerationEnd(ChunkLoadEvent e) {
    if (e.isNewChunk()) {
    //What ever you need to do here
    }
    }

    The documentation for the ChunkLoadEvent is here
     
  3. Offline

    slam5000

    you're right... upon closer inspection of the documentation though, I did notice that the ChunkPopulateEvent is called after the chunk is populated, and a chunk is populated at the end of its generation lifecycle, so if that's what you're looking for Megalos, than you can use ChunkPopulateEvent. Just wondering so I might be of more use, what exactly are you trying to achieve?
     
  4. Offline

    Megolas

    I wanted to empty all chunks over a certain coordinate, yet I can't use a terrain generator since it would also override the default terrain generator
    v10lator, I've seen that, but just to clarify, I meant whether its before or after the chunks are sent, my bad, should have mentioned it. I already found the solution though, thanks.
     
  5. Offline

    slam5000

    OK, so in trying to stop a chunk from generating, you're going beyond the Bukkit API's capabilities. Currently, there's no real way to just stop a chunk from loading. (besides taking the worldborder strategy, and just stopping players from getting close enough to the chunk for it to load.)

    This is due to a weird (not really glitch... but it could be an issue for some coders) mechanic in how the minecraft server loads chunks. If you for example stopped a chunk from generating, bukkit will accept you telling it not to load, but the minecraft server will notice the players's still in range of the of the chunk, and attempt yet again to tell the server to load the chunk. This of course will once again fire the chunk load event... which you will cancel again, creating an infinite loop. If you only want the appearance of there being nothing at that location, you could use player.sendChunkChange() to send a fake empty chunk, but other than that, I don't think you can just stop a chunk from generating.
     
Thread Status:
Not open for further replies.

Share This Page