SHARE
TWEET

Inferno Punch Event

a guest May 11th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @SubscribeEvent
  2.     public static void onInfernoPunch(LivingAttackEvent event) {
  3.         EntityLivingBase entity = (EntityLivingBase) event.getSource().getTrueSource();
  4.         EntityLivingBase target = (EntityLivingBase) event.getEntity();
  5.         Bender ctx = Bender.get(entity);
  6.         if (event.getSource().getTrueSource() == entity && (entity instanceof EntityBender || entity instanceof EntityPlayer) && ctx.getData() != null) {
  7.             Vector direction = Vector.toRectangular(Math.toRadians(entity.rotationYaw), 0);
  8.             AbilityData abilityData = ctx.getData().getAbilityData("inferno_punch");
  9.             float knockBack = 1F;
  10.             int fireTime = 5;
  11.             float damage = 3;
  12.             int punchesLeft = 1;
  13.  
  14.  
  15.             if (abilityData.getLevel() >= 1) {
  16.                 damage = 4;
  17.                 knockBack = 1.25F;
  18.                 fireTime = 6;
  19.             }
  20.             if (abilityData.getLevel() >= 2) {
  21.                 damage = 5;
  22.                 knockBack = 1.5F;
  23.                 fireTime = 8;
  24.                 punchesLeft = 2;
  25.             }
  26.  
  27.             if (abilityData.isMasterPath(AbilityData.AbilityTreePath.FIRST)) {
  28.                 damage = 10;
  29.                 knockBack = 1.75F;
  30.                 fireTime = 15;
  31.                 //Creates a bunch of fire blocks around the target
  32.             }
  33.             if (abilityData.isMasterPath(AbilityData.AbilityTreePath.SECOND)) {
  34.                 damage = 2;
  35.                 knockBack = 0.75F;
  36.                 fireTime = 4;
  37.                 punchesLeft = 3;
  38.             }
  39.  
  40.             if (ctx.getData().hasStatusControl(INFERNO_PUNCH)) {
  41.                 if (entity.getHeldItemMainhand() == ItemStack.EMPTY) {
  42.                     //DamageSource ds = DamageSource.LAVA;
  43.                     DamageSource ds = DamageSource.MAGIC;
  44.                     target.attackEntityFrom(ds, damage);
  45.                     target.setFire(fireTime);
  46.                     punchesLeft--;
  47.                     if (punchesLeft <= 0) {
  48.                         ctx.getData().removeStatusControl(INFERNO_PUNCH);
  49.                     }
  50.                     else if (punchesLeft > 0) {
  51.                         ctx.getData().addStatusControl(INFERNO_PUNCH);
  52.                     }
  53.                     target.motionX += direction.x() * knockBack;
  54.                     target.motionY += direction.y() * knockBack >= 0 ? knockBack / 2 + (direction.y() * knockBack / 2) : knockBack / 2;
  55.                     target.motionZ += direction.z() * knockBack;
  56.                     target.isAirBorne = true;
  57.                     // this line is needed to prevent a bug where players will not be pushed in multiplayer
  58.                     AvatarUtils.afterVelocityAdded(target);
  59.  
  60.                 }
  61.             }
  62.         }
  63.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top