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

Solved Kill arrow if its on ground

Comments in 'Plugin Development' started by thebigsmileXD, Sep 24, 2015.

  1. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Hey!
    I want to kill an arrow if it touches the floor or is in a block..
    inGround.
    I know this:
    PHP:
    public function deleteArrowOnGround(EntityMotionEvent $event){
            if(
    $event->getEntity() instanceof Arrow){
                if(
    $event->getEntity()->onGround){
                    
    $event->getEntity()->kill();
                }
            }
        }
    does not work, because if the arrow is onGround, it doesn't move anymore and the event isn't called anymore.
    Anyone has a different idea?
  2. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Just tried
    PHP:
        public function deleteArrowOnGround(ProjectileHitEvent $event){
            if(
    $event->getEntity() instanceof Arrow){
                
    $event->getEntity()->kill();
            }
        }
    it works, but the arrow is lagging hard.
    PHP:
        public function deleteArrowOnGround(ProjectileHitEvent $event){
            if(
    $event->getEntity() instanceof Arrow){
                if(
    $event->getEntity()->onGround || $event->getEntity()->inBlock || $event->getEntity()->isCollided){
                    
    $event->getEntity()->kill();
                }
            }
        }
    also lags, but not that hard
    Last edited: Sep 24, 2015
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    how lags? and you should use ProjectileHitEvent
    PEMapModder likes this.
  4. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Yea, seems like i only had some wifi problems. The last snippet works perfect :)

Share This Page

Advertisement