Chunks problem

Discussion in 'Plugin Development' started by girardcome, Jan 14, 2015.

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

    girardcome

    I have the following code, however it does not seem to function. this work, except for chunk. When someone did the command /spawn (custom command), it's normally teleport him from a radius of 500x500 max, but i don't know why it's not loading chunks so when a player do the command /spawn it's teleporting him trough the void for 5 to 10 seconds (which is very very very very very very very very very very Boring). Please i need help.

    Code:
    final Location loc = p.getLocation();
                        Random rand = new Random();
                        loc.setX(-500 + rand.nextInt(1000));
                        loc.setZ(-500 + rand.nextInt(1000));
                        loc.setY(p.getWorld().getHighestBlockYAt(loc));
                        loc.getChunk().load(true);
                        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                            public void run() {
                                p.teleport(loc);
                            }
                        }, 20L);
                        return false;
     
  2. Offline

    Konato_K

    That sounds more like the server being slow or the connection.

    @girardcome
     
  3. Offline

    97WaterPolo

    @girardcome
    I believe the chunk becomes unloaded if there isn't a player in it. So either cancel the chunk when it tries to unload VIA the event, or load the chunk when you teleport the player.
     
  4. Offline

    mythbusterma

    @girardcome

    Because the server is generating the chunks underneath him, which takes time. You can solve this by pre-loading the chunks.
     
  5. Offline

    girardcome

  6. Offline

    Quackster

    2L is only 2 ticks.

    Every second is 20 ticks so I'd suggest making the person wait 5 seconds before teleport. Which is 5 * 20
     
Thread Status:
Not open for further replies.

Share This Page