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 }
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.
Something like PHP: ProjectileHitEvent//get nearby entitiesforeach($snowball->getLevel()->getNearbyEntities($snowball->getBoundingBox->grow(0.5, 0.5, 0.5), $nowball) as $e){ //do something with $e, the entities around the snowball}//get nearby blocksforeach($snowball->getBlocksAround() as $block){ //do something with $block, the blocks around the snowball}