Last active
August 29, 2015 14:18
-
-
Save namiken/7f32f758ddfddba3d240 to your computer and use it in GitHub Desktop.
Minecraft Bukkit 方向取得プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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