Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Event for death by void?

Comments in 'Plugin Development' started by dxm_hippie, Apr 21, 2015.

  1. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Just wondering if theres a different event for falling out of the world other than just a deathevent, i looked at the api page and couldn't find it /: im wondering bc i want to try to attempt to make a plugin that will warp a player to lobby instantly when they fall in the void, i seem to have some corrupted region files causing a death loop when someone falls in the void ):
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What about PlayerMoveEvent?
  3. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    PHP:
    public function stopVoid(PlayerMoveEvent $ev){
    $p $ev->getPlayer();
    if(
    intval($p->y) === 0){
      
    $p->teleport($p->getLevel()->getSafeSpawn());
    }
    }
    it is better to do this if your lobby like a skyblock map:
    PHP:
    public function stopVoid(PlayerMoveEvent $ev){
    $p $ev->getPlayer();
    if(
    intval($p->y) < 7){
      
    $p->teleport($p->getLevel()->getSafeSpawn());
    }
    }
    just choose from the 2 snippets...
    dxm_hippie likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. Why intval?
    2. Why === not <=?
  5. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    1. because i somehow prefer to use it than round(). i dont know which is better so ya ...
    2. the first snippet was if the y coordinate of the player is equal to 0, it will teleport him back to spawn. it depends on the user of the code how he would manage it as they all work as intended.
  6. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    Thanks peeps! worked like a charm :) i jump in the void and am tp back to spawn before i even die :D
  7. dxm_hippie
    Offline

    dxm_hippie Active Member Plugin Developer

    Joined:
    Feb 1, 2015
    Posts:
    413
    Plugins:
    1
    Minecraft User:
    XxDXM_hippiexX
    I ended up useing all x y and z bc in one of my worlds i would be stuck at x0,y134,y0
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Are you sure if you want to round or floor? That would do floor if you use intval.
    Anyway `(int) $num` is faster than `intval($num)`, whether $num is integer or floating point, or a string.

Share This Page

Advertisement