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

Solved EnderPearl Landing Pos

Discussion in 'Development' started by Mr174, Feb 17, 2020.

  1. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Is it possible to get the cords on where the Pearl lands?
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    PHP:
    public function onLand(ProjectileHitBlockEvent $ev) {
        
    $b $ev->getBlockHit();
        
    $ent $ev->getEntity();
        if (!
    $ent instanceof Projectile) return;

        
    $shooter $ent->getOwningEntity();
        if (
    $shooter instanceof Player && $ent instanceof EnderPearl){
            if (
    $b->getX() >= 75){
                
    $shooter->sendMessage('no');
            }
        }
    }
        }
    This works just i cant cancel it any other way?
     
    Last edited: Feb 18, 2020
  3. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Attempt 2
    Still teleports the player
    PHP:
    public function onLand(ProjectileHitEvent $ev) {
            
    $owner $ev->getEntity()->getOwningEntity();

            if (
    $owner instanceof Player){
                
    $vector $ev->getRayTraceResult()->getHitVector();
                if (
    $vector->>= 75){
                    
    $owner->sendMessage('Nope');
                    return;
                }
                
    $owner->teleport($vector);
            }
        }
     
  4. Zade

    Zade Spider

    Messages:
    11
    Add $event->setCancelled(true); before the return;
     
  5. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    The event is not cancellable
    Im still not clear on what you are trying to achieve, are you trying to cancel the teleportation?
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Yes, i figured it out! I had to make my own Ender Pearl
     
  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.