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 {
	public SpellLaunch(int id,String name){
		super(id,name);
	}
	private static final float power = 1.4F;
	@Override
	public boolean cast(World world, EntityPlayer player, BlockPos pos, EnumFacing side ) {

		player.motionY = 0;
		player.fallDistance = 0;
		
		double velX;
		double velY = (double) (-MathHelper.sin((player.rotationPitch) / 180.0F * (float) Math.PI) * power);
		double velZ;
		
		if(player.isSneaking()){
			//then do vertical only
			velX = 0;
			velZ = 0;
			if (velY < 0) {
				velY *= -1;// make it always up never down
			}
			//power = 1.8F;
			velY *= (power / 2);
		}
		else{
			velX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * power);
			velZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) * power);
			
			// launch the player up and forward at minimum 30 degrees
			// regardless of look vector
			if (velY < 0) {
				velY *= -1;// first invert direction
			}
			if (velY < 0.4) {
				// if you are looking straight ahead, this is zero

				velY = 0.4 + player.jumpMovementFactor;// do a bit of a
			}
		}

		System.out.println(velX  +":"+ velY +":"+ velZ);
		player.addVelocity(velX, velY, velZ);
		
		return true;
	}
}

@@ -294,16 +294,62 @@
 Spell %7B%0A
+%09%0A%09private static final float power = 1.1F;%0A%09%0A
 %09public 
@@ -407,48 +407,8 @@
 %09%7D%0A%09
-private static final float power = 1.4F;
 %0A%09@O
@@ -689,16 +689,85 @@
 le velZ;
+%0A%0A%09%09if (velY %3C 0) %7B%0A%09%09%09velY *= -1;// make it always up never down%0A%09%09%7D
 %0A%09%09%0A%09%09if
@@ -845,33 +845,17 @@
 = 0;%0A%09%09%09
-if (velY %3C 0) %7B%0A%09
+%0A
 %09%09%09velY 
@@ -861,90 +861,35 @@
  *= 
--1;// make it always up never down%0A%09%09%09%7D%0A%09%09%09//power = 1.8F;%0A%09%09%09velY *= (
+2 ;//and pump up the 
 power 
-/ 2);
 %0A%09%09%7D
@@ -1076,16 +1076,17 @@
 ouble) (
+ 
 MathHelp
@@ -1316,149 +1316,29 @@
 tor%0A
-%09%09%09if (velY %3C 0) %7B%0A%09%09%09%09velY *= -1;// first invert direction%0A%09%09%09%7D%0A%09%09%09if (velY %3C 0.4) %7B%0A%09%09%09%09// if you are looking straight ahead, this is zero%0A
+%0A%09%09%09if (velY %3C 0.4) %7B
 %0A%09%09%09
@@ -1408,59 +1408,8 @@
 %09%7D%0A%0A
-%09%09System.out.println(velX  +%22:%22+ velY +%22:%22+ velZ);%0A
 %09%09pl

decrease launch power