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

Spawnprotection

Discussion in 'Development' started by Jonas, Mar 25, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    How can I make a spawnprotection in a 5 block radius where you dont can to add Damage
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    cancel it when it's near spawn
     
  3. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Can you give me an example
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    check distance
     
  5. Jonas

    Jonas Baby Zombie

    Messages:
    192
    How?
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Using distance function.
    PHP:
    public function onDamage(EntityDamageEvent $e){
    $spawn $this->getServer()->getDefaultLevel()->getSafeSpawn();
    $p =$e->getEntity();
    $distance $p->distance($spawn);
    if(
    $p instanceof Player){
    if(
    $distance 10){
    $e->setCancelled();
    }
    }
    }
     
  7. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Ok in which event can i use that ?
     
  8. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Read my post, I edited it. And use logic... You want to block damage, so?? :v
     
  9. Jonas

    Jonas Baby Zombie

    Messages:
    192
    It dosn't work in a distance from 100 Blocks i don't got damage
     
  10. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Wait, you want to add damage to player or block it?
     
  11. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Block it
     
  12. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I seems my code to be ok for blocking it
     
  13. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Yes the code is right but its < Not >
     
  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.