Advertisement
Zyded

Untitled

May 31st, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. public class Location {
  2. private double x;
  3. private double y;
  4. private double z;
  5. private float yaw;
  6. private float pitch;
  7.  
  8. public Location(double x, double y, double z, float yaw, float pitch) {
  9. this.x = x;
  10. this.y = y;
  11. this.z = z;
  12. this.yaw = yaw;
  13. this.pitch = pitch;
  14. }
  15.  
  16. public Location(double x, double y, double z) {
  17. this.x = x;
  18. this.y = y;
  19. this.z = z;
  20. this.yaw = 0.0F;
  21. this.pitch = 0.0F;
  22. }
  23.  
  24. public Location(int x, int y, int z) {
  25. this.x = (double)x;
  26. this.y = (double)y;
  27. this.z = (double)z;
  28. this.yaw = 0.0F;
  29. this.pitch = 0.0F;
  30. }
  31.  
  32. public Location add(int x, int y, int z) {
  33. this.x += (double)x;
  34. this.y += (double)y;
  35. this.z += (double)z;
  36. return this;
  37. }
  38.  
  39. public Location add(double x, double y, double z) {
  40. this.x += x;
  41. this.y += y;
  42. this.z += z;
  43. return this;
  44. }
  45.  
  46. public Location subtract(int x, int y, int z) {
  47. this.x -= (double)x;
  48. this.y -= (double)y;
  49. this.z -= (double)z;
  50. return this;
  51. }
  52.  
  53. public Location subtract(double x, double y, double z) {
  54. this.x -= x;
  55. this.y -= y;
  56. this.z -= z;
  57. return this;
  58. }
  59.  
  60. public Block getBlock() {
  61. return Minecraft.getMinecraft().theWorld.getBlockState(this.toBlockPos()).getBlock();
  62. }
  63.  
  64. public double getX() {
  65. return this.x;
  66. }
  67.  
  68. public Location setX(double x) {
  69. this.x = x;
  70. return this;
  71. }
  72.  
  73. public double getY() {
  74. return this.y;
  75. }
  76.  
  77. public Location setY(double y) {
  78. this.y = y;
  79. return this;
  80. }
  81.  
  82. public double getZ() {
  83. return this.z;
  84. }
  85.  
  86. public Location setZ(double z) {
  87. this.z = z;
  88. return this;
  89. }
  90.  
  91. public float getYaw() {
  92. return this.yaw;
  93. }
  94.  
  95. public Location setYaw(float yaw) {
  96. this.yaw = yaw;
  97. return this;
  98. }
  99.  
  100. public float getPitch() {
  101. return this.pitch;
  102. }
  103.  
  104. public Location setPitch(float pitch) {
  105. this.pitch = pitch;
  106. return this;
  107. }
  108.  
  109. public static Location fromBlockPos(BlockPos blockPos) {
  110. return new Location(blockPos.getX(), blockPos.getY(), blockPos.getZ());
  111. }
  112.  
  113. public BlockPos toBlockPos() {
  114. return new BlockPos(this.getX(), this.getY(), this.getZ());
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement