Created
June 5, 2017 18:32
-
-
Save Densyakun/e513e84c86cff2d8c2e12f74fa20e65f to your computer and use it in GitHub Desktop.
Minecraftのベクトルの方向を方角に変換します。
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
package io.github.densyakun.bukkit.automine; | |
public enum Direction { | |
zero, left, right, down, up, back, forward; | |
public static Direction getDirection(double x, double y, double z) { | |
if (x < y) { | |
if (y < -x) { | |
if (-x < z) { | |
return forward; | |
} else if (-x < -z) { | |
return back; | |
} else { | |
return left; | |
} | |
} else { | |
if (y < z) { | |
return forward; | |
} else if (y < -z) { | |
return back; | |
} else { | |
return up; | |
} | |
} | |
} else if (x == 0 && y == 0) { | |
return zero; | |
} else { | |
if (-y < x) { | |
if (x < z) { | |
return forward; | |
} else if (x < -z) { | |
return back; | |
} else { | |
return right; | |
} | |
} else { | |
if (-y < z) { | |
return forward; | |
} else if (-y < -z) { | |
return back; | |
} else { | |
return down; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment