Loading Chunks Before Teleporting

Discussion in 'Plugin Development' started by Saxon564, Sep 9, 2013.

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

    Saxon564

    I have a randomTP plugin that I made, but the problem that we keep getting is that if it teleports you to a new chunk you will sometimes die because you get stuck in solid blocks, or fall into the void. I'm wondering if there is a way to make the chunk load/generate before the player gets teleported.
     
  2. Offline

    metalhedd

  3. Offline

    SuperOmegaCow

  4. Offline

    CoderCloud

    You can use world.loadChunk(x, y), to generate the chunk.
     
  5. Offline

    Saxon564

    metalhedd & SuperOmegaCow: I am looking at the pages you gave me now, maybe they will help, thank you for the links, and i will let you know.

    CoderCloud: is the x, y the teleport coords or the chunk coords?
    e.g. is world.loadChunk(100, 100) going to load chunk 100, 100 or is it going to load the chunk that contains x = 100 and y = 100
     
  6. Offline

    The_Doctor_123

    Saxon564

    It will load the chunk with the chunk coordinates, not block coordinates.
     
  7. Offline

    Saxon564

  8. Offline

    The_Doctor_123

    Saxon564

    If you're having trouble, I believe there is a getChunk() method in Location.
     
  9. Offline

    jayfella

    it will load the chunk with co-ordinate 100, 100. The code below shows how to convert regular location co-ords to chunk co-ords and back again using bitshifting:

    Code:java
    1.  
    2. int chunkLocationX = player.getLocation.getBlockX() >> 4;
    3. int playerLocationX = chunkLocationX << 4;
    4.  
     
  10. Offline

    xize

    you could define a location then use

    Code:
    loc.getWorld().refreshChunk(loc.getChunk().getX(), loc.getChunk().getZ());
    
    it forces to generate chunks to before the player teleports;)

    credits to codenameB though :)
     
    PocketMines likes this.
Thread Status:
Not open for further replies.

Share This Page