Resource Guide to use entity as projectile

Discussion in 'Spigot Plugin Development' started by Michel_0, Aug 3, 2018.

  1. Hi there,

    i'm currently developing a gamemode, where player can launch > "stuff" < to demolish each others buildings.
    I've done some research (by collecting others experience in forums and mostly by testing by myself) about several entities.
    However, there doesn't seem to be a place to discuss and share experiences in handling projectiles.
    That's why i create this thread, to share my knowledge and to receive more experiences from forum-readers for forum-readers with the same problem.

    Preconditions are:

    • The projectile needs to be affected by gravity to have a well formed flight curve
    • There must be an event to safely completely eliminate any effect when the projectile hits ground or something else (because i want to decide the effects like explosions,... by myself, independent of the projectile)
    • They shouldn't be mobs or so since i don't want to throw zombies or similar (altouth this would be funny, too)
    I spotted these possible entities:
      Not properly affected by gravity
      Would be nice, but i didn't get it managed to have this less power to fall down again
      Good choice
      ProjectileHitEvent (only informative) and EntityDamageByEntityEvent (to be cancelled)
      Also suitable
      ProjectileHitEvent (only informative), EntityDamageByEntityEvent (to be cancelled) and CreatureSpawnEvent (SpawnReason.DISPENSE_EGG, to be cancelled)
      EntityDamageByEntityEvent (to be cancelled) and EntityExplodeEvent (to be cancelled)
      However you can't detect, when the block hits the ground or an obstacle, only when the fuse is over and the thingy explodes (maybe even in air)
      EntityChangeBlockEvent (to be cancelled) ItemSpawnEvent (find nearby FallingBlock entities, to be cancelled)
    "to be cancelled" means, to be cancelled, only when it acutally is the projectile, which has been launched.
    Have you ever had the same problem and how did you solve it?
    Do you see any way to hadle those entities marked as unsuitable?
    Did i forget any projectile?

    EDIT: I ignored solutions by scheduling some runnables to check something on each server tick.
  2. 1.13 added the Tridents which, when thrown without riptide, are a Projectile instance. Since they extend the Arrow class, they too should be affected properly by gravity. Pretty sure when created, they call the ProjectileSpawnEvent & upon hit a ProjectileHitEvent and/or EntityDamageByEntityEvent.