Solved Custom Entity Attack Speed NPE

Discussion in 'Spigot Plugin Development' started by PillBox_, Feb 14, 2020.

  1. Hello all. So I'm trying to adjust the attack speed of a custom mob (zombie) and I'm getting a NPE when trying to adjust the attack speed. Adjusting the Max-Health with attributes is working fine with no NPEs.

    Just curious what would cause a Attack-Speed attribute adjustment to throw NPE?

    Code (Java):
    zombie.getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(aSpeed);
     
  2. getAttribute is annotated Nullable so I suppose a Zombie does not have an Attribute Attack speed
     
  3. Try adding the attribute to the zombie as zombie probably doesn’t originally have it or you could do it in an entitydamage event
     
  4. Yup, that'll do it lol thanks.