Skip to content

Instantly share code, notes, and snippets.

@namiken
Last active August 29, 2015 14:18
Show Gist options
  • Save namiken/7f32f758ddfddba3d240 to your computer and use it in GitHub Desktop.
Save namiken/7f32f758ddfddba3d240 to your computer and use it in GitHub Desktop.
Minecraft Bukkit 方向取得プログラム
import org.bukkit.Location;
public class DirectionUtil {
/**
* 向いている方向のベクトルを取得する
* @param l
* @param length 引数のLocationからどれだけ離れているか?
* @return
*/
public static Location methodA(Location l, double length) {
float pitch = getPitch(l);
float yaw = getYaw(l);
return l.add(new Location(l.getWorld(), -length * Math.sin(yaw) * Math.cos(pitch), -length * Math.sin(pitch), length * Math.cos(yaw) * Math.cos(pitch)));
}
/**
* 自分と同じ高さで向いている方向の座標を取得する
* @param l
* @param length 引数のLocationからどれだけ離れているか?
* @return
*/
public static Location methodB(Location l, double length) {
float pitch = getPitch(l);
float yaw = getYaw(l);
return l.add(new Location(l.getWorld(), -length * Math.sin(yaw) * Math.cos(pitch),0, length * Math.cos(yaw) * Math.cos(pitch)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment