package com.lothrazar.cyclicmagic.spell;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class SpellLaunch extends BaseSpell implements ISpell {
	
	private static final float power = 1.005F;
	
	public SpellLaunch(int id,String name){
		super(id,name);
		this.cost = 15;
	}
	
	@Override
	public boolean cast(World world, EntityPlayer player, BlockPos pos, EnumFacing side ) {

		player.motionY = 0;
		player.fallDistance = 0;
		
		double velY = (double) (-MathHelper.sin((player.rotationPitch) / 180.0F * (float) Math.PI) * power);

		if (velY < 0) {
			velY *= -1;// make it always up never down
		}
		// launch the player up and forward at minimum angle
		// regardless of look vector
		
		if (velY < 0.4) {
			velY = 0.4 + player.jumpMovementFactor;
		}
	
		double velX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * power);
		double velZ = (double) ( MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * power);
		
		player.addVelocity(velX, velY, velZ);
		
		return true;
	}
}

@@ -294,17 +294,16 @@
 Spell %7B%0A
-%09
 %0A%09privat
@@ -340,16 +340,63 @@
 .005F;%0A%09
+private static final float mountPower = 1.01F;%0A
 %0A%09public
@@ -415,16 +415,17 @@
 (int id,
+ 
 String n
@@ -428,16 +428,17 @@
 ng name)
+ 
 %7B%0A%09%09supe
@@ -442,16 +442,17 @@
 uper(id,
+ 
 name);%0A%09
@@ -471,17 +471,16 @@
  15;%0A%09%7D%0A
-%09
 %0A%09@Overr
@@ -571,65 +571,13 @@
 side
- 
 ) %7B%0A%0A
-%09%09player.motionY = 0;%0A%09%09player.fallDistance = 0;%0A%09%09
 %0A%09%09d
@@ -831,18 +831,16 @@
  vector%0A
-%09%09
 %0A%09%09if (v
@@ -899,17 +899,16 @@
 or;%0A%09%09%7D%0A
-%09
 %0A%09%09doubl
@@ -1091,17 +1091,16 @@
 ouble) (
- 
 MathHelp
@@ -1233,53 +1233,371 @@
 r);%0A
+%0A
 %09%09
-%0A%09%09player.addVelocity(velX, velY, velZ);%0A%09%09
+if (player.ridingEntity != null) %7B%0A%09%09%09// boost power a bit, horses are heavy as F%0A%09%09%09player.ridingEntity.addVelocity(velX * mountPower, velY * mountPower, velZ * mountPower);%0A%0A%09%09%09player.ridingEntity.motionY = 0;%0A%09%09%09player.ridingEntity.fallDistance = 0;%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09player.addVelocity(velX, velY, velZ);%0A%09%09%7D%0A%09%09player.motionY = 0;%0A%09%09player.fallDistance = 0;%0A
 %0A%09%09r

make launch spell work on what you are riding - horses