Projectiles colliding with other projectiles?

Discussion in 'Spigot Plugin Development' started by Faceguy, Jun 13, 2016.

  1. So I've been screwing around for the past few days trying to figure this out, but I haven't had any luck. Is there a way to listen for projectiles colliding with other projectiles?

    Currently, when arrows collide with shulker projectiles, they both are removed. I would like to make it so that when the collide, either a small explosion is triggered, or only the shulker projectile is destroyed. Through various searches and debugs in all the usual spots, I haven't been able to find an event being fired when this happens.

    So! Have I missed something? Or is it just not possible? Thanks in advance for any info/assistance!
     
  2. My best bet would be to test if an arrow hits the shulker projectile and summon a PrimedTnt about to explode.
     
    • Funny Funny x 1
  3. Fair, though what I really need to solve is how to test for that collision :D
     
  4. I'm afraid I'm not seeing how editing the size of the hitbox would help. They DO collide properly already, I just need to be able to listen for that collision, and do things when it occurs.

    Unless you mean I should constantly check if fired arrows are within a hitbox every tick but... that seems... rather intensive.
     
  5. Maybe listen for ProjectileHitEvent and/or EntityDamageByEntityEvent. The last would be the best but I don't know which events would be fired in your case TBH so I would either do it by trail and error to see which ones fire or dig into the code ;).
     
  6. Maybe create a BukkitRunnable when the arrow is shot and test if a projectile is within 1 block of it
     
  7. Yeah that's what I was thinking. I mean, in single player mode minecraft has to check for it somehow so it couldn't be too horrible. You could listen for a packet that's sent when they are both removed or something. If there is an event that is fired, I think you can listen for the type Event in a listener class and see what events are fired. (I'm sure there's someway to do that)
     
  8. Using ProjectileHitEvent you can only get the arrow and not the shulker bullet. No EntityDamageByEntity is fired.
    If you spawn the bullet yourself you can override the collide method in the nms EntityShulkerBullet class.
    If it is spawned by a Shulker instead you'll have to also override the nms EntityShulker class to spawn the custom bullet.
     
  9. I'm not sure of the order things happen in but if the shulker bullet has not been removed/despawned then you could check for nearby entities in the ProjectileHitEvent event. Even if the shulker bullet is removed first if there is an event that is fired when it's removed/despawned you could store that information in the plugin and check during ProjectileHitEvent.
     
  10. I agree with the first part, but you have to test wether the shulker bullet isn't already removed when the event fires. Regarding the second part, there is no event fired when it is removed.