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

Snowball

Comments in 'Plugin Development' started by Flabe, Jan 17, 2016.

  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello guys , i wanna create special snowball and check when it hits some block or entity , how do i make this , i know i am noob but i need some help please...
    so i want something like this(its just to help you understand me its NOT A CODE):
    create snowball name ="SOMETHING"
    If Something hits block{
    some code
    }
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    In ProjectileHitEvent, check if the bounding box of the projectile intersects with that of other entities or blocks.

    You also need to correct your understanding of programming. The "if" in programming means "if", not "when". "if" checks a currently occurring condition. If you do it immediately after spawning the snowball, it is pointless because you don't expect the snowball to collide with any blocks or entities upon spawning. Therefore, it is not an "if" immediately after spawn that you want, as you mentioned in your main post. Instead, it is a "when", i.e. an event, where "when" a projectile collides with another entity or a block, do something.
    CraftYourBukkit and wolfdale like this.
  3. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Something like
    PHP:
    ProjectileHitEvent
    //get nearby entities
    foreach($snowball->getLevel()->getNearbyEntities($snowball->getBoundingBox->grow(0.50.50.5), $nowball) as $e){
            
    //do something with $e, the entities around the snowball
    }
    //get nearby blocks
    foreach($snowball->getBlocksAround() as $block){
            
    //do something with $block, the blocks around the snowball
    }

Share This Page

Advertisement