package com.github.tuserver.api.world;
import com.github.tuserver.api.block.Block;
public class Location implements Cloneable {
private World world;
private double x;
private double y;
private double z;
private float pitch;
private float yaw;
public Location(World world, double x, double y, double z) {
this(world, x, y, z, 0, 0);
}
public Location(World world, double x, double y, double z, float pitch) {
this(world, x, y, z, pitch, 0);
}
public Location(World world, double x, double y, double z, float pitch, float yaw) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.pitch = pitch;
this.yaw = yaw;
}
public int getBlockX() {
return (int) x; // TODO
}
public int getBlockY() {
return (int) y; // TODO
}
public int getBlockZ() {
return (int) z; // TODO
}
public World getWorld() {
return world;
}
public Block getBlock() {
return world.getBlock(getBlockX(), getBlockY(), getBlockZ());// TODO
}
public Chunk getChunk() {
return world.getChunkFromBlockCoords(getBlockX(), getBlockZ());
}
public void setWorld(World world) {
this.world = world;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
public float getYaw() {
return yaw;
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Location other = (Location) obj;
if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
return false;
}
if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
return false;
}
if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) {
return false;
}
if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) {
return false;
}
if (Float.floatToIntBits(this.pitch) != Float.floatToIntBits(other.pitch)) {
return false;
}
if (Float.floatToIntBits(this.yaw) != Float.floatToIntBits(other.yaw)) {
return false;
}
return true;
}
}