PreLoading Chunks

Discussion in 'Plugin Development' started by The Gaming Grunts, Feb 23, 2014.

Thread Status:
Not open for further replies.
  1. Hey everyone! So I was wondering if the following code is the best way of preloading chunks when a player teleports and if it isn't then what's the best way to do it. I'm simply doing this for a smoother transition when a player teleports between locations. Thanks :)

    Code:java
    1. @EventHandler
    2. public void onTeleport(PlayerTeleportEvent e){
    3. World to = e.getTo().getWorld();
    4.  
    5. if (!to.getChunkAt(e.getTo()).isLoaded())
    6. to.loadChunk(e.getTo().getChunk());
    7. }
     
  2. Offline

    The Fancy Whale

    If I were you I would do:
    on player teleport if chunk is not loaded, cancel the teleport and load the chunk. Then reteleport them if that makes sense.
     
  3. Offline

    xize

    The Gaming Grunts
    you could also do getWorld().refreshChunk(x, z) which is a little bit faster in loading:)
     
Thread Status:
Not open for further replies.

Share This Page