package com.choonster.testmod3.command;

import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3i;

import javax.vecmath.AxisAngle4d;
import javax.vecmath.Matrix3d;
import javax.vecmath.Matrix4d;
import javax.vecmath.Vector3d;
import java.util.Locale;

/**
 * A command that rotates a vector around the specified axis by the specified amount.
 *
 * @author Choonster
 */
public class CommandRotateVector extends CommandBase {

	/**
	 * Return the required permission level for this command.
	 */
	@Override
	public int getRequiredPermissionLevel() {
		return 0;
	}

	/**
	 * Gets the name of the command.
	 */
	@Override
	public String getCommandName() {
		return "rotate-vector";
	}

	/**
	 * Gets the usage string for the command.
	 *
	 * @param sender The command sender that executed the command
	 */
	@Override
	public String getCommandUsage(ICommandSender sender) {
		return "commands.testmod3.rotateVector.usage";
	}

	/**
	 * Callback when the command is invoked.
	 *
	 * @param sender The command sender that executed the command
	 * @param args   The arguments that were passed
	 */
	@Override
	public void processCommand(ICommandSender sender, String[] args) throws CommandException {
		if (args.length < 5) throw new WrongUsageException("commands.testmod3.rotateVector.usage");

		final double x = parseDouble(args[0]), y = parseDouble(args[1]), z = parseDouble(args[2]);
		final Vector3d inputVector = new Vector3d(x, y, z);

		final EnumFacing.Axis axis = EnumFacing.Axis.byName(args[3].toLowerCase(Locale.ENGLISH));
		if (axis == null) throw new WrongUsageException("commands.testmod3.rotateVector.invalidAxis");

		// Get the positive facing for the axis then get its direction vector
		final Vec3i axisVector = EnumFacing.func_181076_a(EnumFacing.AxisDirection.POSITIVE, axis).getDirectionVec();

		final int degrees = parseInt(args[4]);

		final AxisAngle4d axisAngle = new AxisAngle4d(axisVector.getX(), axisVector.getY(), axisVector.getZ(), Math.toRadians(degrees));

		final Matrix3d rotationMatrix = new Matrix3d();
		rotationMatrix.set(axisAngle);

		final Vector3d outputVector = new Vector3d();
		rotationMatrix.transform(inputVector, outputVector);

		sender.addChatMessage(new ChatComponentTranslation("commands.testmod3.rotateVector.result", outputVector.getX(), outputVector.getY(), outputVector.getZ()));
	}
}

@@ -34,16 +34,64 @@
 mmand;%0A%0A
+import com.choonster.testmod3.util.VectorUtils;%0A
 import n
@@ -360,173 +360,37 @@
 ng;%0A
-import net.minecraft.util.MathHelper;%0Aimport net.minecraft.util.Vec3i;%0A%0Aimport javax.vecmath.AxisAngle4d;%0Aimport javax.vecmath.Matrix3d;%0Aimport javax.vecmath.Matrix4
+%0Aimport javax.vecmath.Matrix3
 d;%0Ai
@@ -1578,22 +1578,16 @@
 %5B2%5D);%0A%09%09
-final 
 Vector3d
@@ -1821,361 +1821,44 @@
 %0A%0A%09%09
-// Get the positive facing for the axis then get its direction vector%0A%09%09final Vec3i axisVector = EnumFacing.func_181076_a(EnumFacing.AxisDirection.POSITIVE, axis).getDirectionVec();%0A%0A%09%09final int degrees = parseInt(args%5B4%5D);%0A%0A%09%09final AxisAngle4d axisAngle = new AxisAngle4d(axisVector.getX(), axisVector.getY(), axisVector.getZ(), Math.toRadians(degrees)
+final int degrees = parseInt(args%5B4%5D
 );%0A%0A
@@ -1895,27 +1895,24 @@
 x = 
-new Matrix3d();%0A%09%09r
+VectorUtils.getR
 otat
@@ -1924,74 +1924,42 @@
 trix
-.set
 (axis
-Angle);%0A%0A%09%09final Vector3d outputVector = new Vector3d(
+, Math.toRadians(degrees)
 );%0A
+%0A
 %09%09ro
@@ -1992,30 +1992,16 @@
 utVector
-, outputVector
 );%0A%0A%09%09se
@@ -2090,19 +2090,18 @@
 esult%22, 
-out
+in
 putVecto
@@ -2106,27 +2106,26 @@
 tor.getX(), 
-out
+in
 putVector.ge
@@ -2134,11 +2134,10 @@
 (), 
-out
+in
 putV

Use new VectorUtils methods