Jump.java 859 B

12345678910111213141516171819202122232425262728293031
  1. package me.km.effects.active;
  2. import me.km.api.Utils;
  3. import me.km.effects.ActiveEffectBase;
  4. import net.minecraft.entity.player.EntityPlayerMP;
  5. import net.minecraft.util.math.Vec3d;
  6. public class Jump extends ActiveEffectBase
  7. {
  8. @Override
  9. protected boolean executeEffect(EntityPlayerMP p, int power)
  10. {
  11. if(!p.onGround)
  12. {
  13. return false;
  14. }
  15. Vec3d v = p.getLookVec();
  16. double groundLength = Math.sqrt(v.x * v.x + v.z * v.z);
  17. Vec3d goal = new Vec3d(v.x, groundLength * 1.732050807568877, v.z); // 60° shot
  18. goal = goal.normalize();
  19. goal = goal.scale(Math.sqrt((power + 0.85d) / 0.26) / 4);
  20. Utils.setVelocity(p, goal.x, goal.y, goal.z);
  21. return true;
  22. }
  23. @Override
  24. protected int getManaCost(int manaFactor)
  25. {
  26. return 2 * manaFactor;
  27. }
  28. }