Advertisement
Guest User

Ability Earth Spike

a guest
Oct 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. public class AbilityEarthSpikes extends Ability {
  2.  
  3.  
  4. public AbilityEarthSpikes() {
  5. super(Earthbending.ID, "earthspike");
  6. }
  7.  
  8. @Override
  9. public void execute(AbilityContext ctx) {
  10.  
  11. AbilityData abilityData = ctx.getData().getAbilityData(this);
  12. float damage = 0.90F;
  13. float xp = abilityData.getTotalXp();
  14. float ticks = 100;
  15. EntityLivingBase entity = ctx.getBenderEntity();
  16. World world = ctx.getWorld();
  17. Bender bender = ctx.getBender();
  18.  
  19. float chi = STATS_CONFIG.chiEarthspike;
  20. if (ctx.isMasterLevel(AbilityData.AbilityTreePath.FIRST)) {
  21. chi *= 2.5f;
  22. damage = 1.25f;
  23. }
  24. if (ctx.getLevel() == 1 || ctx.getLevel() == 2) {
  25. chi *= 1.5f;
  26. damage = 1F;
  27. ticks = 150;
  28. }
  29. if (ctx.isMasterLevel(AbilityData.AbilityTreePath.SECOND)) {
  30. chi *= 2f;
  31. damage = 1.5F;
  32. ticks = 200;
  33.  
  34. }
  35.  
  36. if (bender.consumeChi(chi)) {
  37. EntityEarthspikeSpawner earthspike = new EntityEarthspikeSpawner(world);
  38. Vector look = Vector.toRectangular(Math.toRadians(entity.rotationYaw), 0);
  39. double mult = ctx.getLevel() >= 1 ? 14 : 8;
  40. double speed = 3;
  41.  
  42. if (abilityData.getLevel() == 1) {
  43. earthspike.setVelocity(look.times(mult * 5));
  44.  
  45. }
  46. if (abilityData.isMasterPath(AbilityData.AbilityTreePath.SECOND)) {
  47. earthspike.setVelocity(look.times(mult * 10));
  48.  
  49. }
  50. if (abilityData.getLevel() <= 2 || abilityData.isMasterPath(AbilityData.AbilityTreePath.SECOND)) {
  51.  
  52.  
  53. earthspike.setOwner(entity);
  54. earthspike.setPosition(entity.posX, entity.posY, entity.posZ);
  55. earthspike.setVelocity(look.times(mult));
  56. earthspike.setDamageMult(damage + xp / 100);
  57. earthspike.maxTicks(ticks);
  58. earthspike.isUnstoppable(ctx.isMasterLevel(AbilityData.AbilityTreePath.SECOND));
  59. world.spawnEntity(earthspike);
  60. }
  61.  
  62. if (abilityData.isMasterPath(AbilityData.AbilityTreePath.FIRST)) {
  63.  
  64. for (int i = 0; i < 8; i++) {
  65.  
  66. Vector direction1 = Vector.toRectangular(Math.toRadians(entity.rotationYaw +
  67. i * 45), 0);
  68. Vector velocity = direction1.times(speed);
  69. EntityEarthspikeSpawner spawner = new EntityEarthspikeSpawner(world);
  70.  
  71. spawner.setVelocity(velocity);
  72. earthspike.maxTicks(ticks);
  73. spawner.setOwner(entity);
  74. spawner.setPosition(entity.posX, entity.posY, entity.posZ);
  75. spawner.setDamageMult(damage + xp / 100);
  76. world.spawnEntity(spawner);
  77. }
  78. }
  79.  
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement