LOOHP-Limbo/src/com/loohp/limbo/Location/Location.java

130 lines
2.6 KiB
Java

package com.loohp.limbo.Location;
import com.loohp.limbo.World.World;
public class Location {
World world;
double x;
double y;
double z;
float yaw;
float pitch;
public Location(World world, double x, double y, double z, float yaw, float pitch) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
}
public Location(World world, double x, double y, double z) {
this(world, x, y, z, 0, 0);
}
@Override
public Location clone() {
return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
}
public World getWorld() {
return world;
}
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 getYaw() {
return yaw;
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
@Override
public String toString() {
return "Location{" + "world=" + world + ",x=" + x + ",y=" + y + ",z=" + z + ",pitch=" + pitch + ",yaw=" + yaw + "}";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(pitch);
result = prime * result + ((world == null) ? 0 : world.hashCode());
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + Float.floatToIntBits(yaw);
temp = Double.doubleToLongBits(z);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Location other = (Location) obj;
if (Float.floatToIntBits(pitch) != Float.floatToIntBits(other.pitch))
return false;
if (world == null) {
if (other.world != null)
return false;
} else if (!world.equals(other.world))
return false;
if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
return false;
if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
return false;
if (Float.floatToIntBits(yaw) != Float.floatToIntBits(other.yaw))
return false;
if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
return false;
return true;
}
}