Solved Change damage of arrow based on force

Discussion in 'Plugin Development' started by Xp10d3, Jun 8, 2021.

  1. Offline

    Xp10d3

    Hello. I'm attempting to change the damage of the arrow based on the force. A lot like ArticMC, I want the damage of the arrow to be dependent on event.getForce() or the momentum of the arrow. If the force is less than 0.2 (ex. 0.1), make the damage very small. If the force is around 0.5, make the damage the same. If the force is around 1, make the damage larger. The only issue is that EntityDamageEvent doesn't track the force/momentum of the arrow; only BowShootEvent does.
     
  2. Offline

    davidclue

    In BowShootEvent attach metadata with the name of your plugin and the force. In EntityDamageEvent just check if it's an instance of an arrow and since you are applying metadata to every arrow there is no need to check if they have your metadata, simply just get the metadata and parse the attached force.
     
  3. Offline

    Xp10d3

    Thanks; that was helpful. However I'm confused since I don't know how I would check if the damage dealt in EntityDamageEvent is an instance of the arrow if there isn't a way to get the arrow itself...?
     
  4. Offline

    davidclue

    @Xp10d3 whoops use EntityDamageByEntity event and then
    Code:
    if (!(e.getDamager() instanceof Arrow)) return;
     
  5. Offline

    Xp10d3

    Works; thanks!
     

Share This Page