1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Chunk

Discussion in 'Development' started by Joao Nunes, Aug 12, 2020.

  1. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    Hello, I'm having problems with my server, when players change the world, as the chunk is not loaded they are getting stuck underground. I believe if I cancel the PlayerMoveEvent when the chunk is not loaded for them I will not continue with this problem, however I have no idea how to do this.
     
    Hipster likes this.
  2. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    What you could do is make it so on EntityLevelChangeEvent you add a delayed task which stops player movement for a few ticks
     
  3. Hipster

    Hipster Zombie

    Messages:
    214
    happening with me too
     
  4. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    I belive this solve the problem,

     
  5. Hipster

    Hipster Zombie

    Messages:
    214
    Seems too complicated for a basic world teleport where the chunk is loaded already...
     
  6. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    What's 4 seconds for player? Kk
     
  7. esh123cookie

    esh123cookie Baby Zombie

    Messages:
    104
    GitHub:
    esh123cookie
    what you could do is this


    PHP:
    public function onLevelChange(EntityLevelChangeEvent $event) {
    $player $event->getEntity();
    if(
    $entity instanceof Player) {
        
    $time 4//ticks
        
    if(!isset($this->coodown[$player->getName()])){
        
    $this->cooldown[$player->getName()] = time() + $time;
        }
    }
    }

    public function 
    onMove(PlayerMoveEvent $event) {
         if(
    time() < $this->coodown[$player->getName()]){
             
    $event->setCancelled();
        }else{
             unset(
    $this->cooldown[$player>getName()]);
             }
    }    
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.