Advertisement
Guest User

Untitled

a guest
May 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class Location(var x: Double, var y: Double, var z: Double, var yaw : Float = 0F, var pitch: Float = 0F) : Cloneable {
  2.  
  3. val blockX: Int get() {
  4. return x.toInt()
  5. }
  6. val blockY: Int get() {
  7. return y.toInt()
  8. }
  9. val blockZ: Int get() {
  10. return z.toInt()
  11. }
  12. val chunkX: Int get() {
  13. return blockX shr 4
  14. }
  15. val chunkZ: Int get() {
  16. return blockZ shr 4
  17. }
  18.  
  19. fun add(direction: Direction) {
  20. x += direction.x
  21. y += direction.y
  22. z += direction.z
  23. }
  24.  
  25. fun getRelative(direction: Direction, times: Int = 1) : Location {
  26. val location = clone();
  27. for (i in 0..times - 1) {
  28. location.add(direction)
  29. }
  30.  
  31. return location
  32. }
  33.  
  34. override fun clone() : Location {
  35. return super.clone() as Location
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement