доблены тесты для сравнения Location's
This commit is contained in:
@@ -8,6 +8,8 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import mc.core.world.World;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class EntityLocation extends Location implements Cloneable {
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -31,4 +33,19 @@ public class EntityLocation extends Location implements Cloneable {
|
||||
public EntityLocation clone() {
|
||||
return (EntityLocation) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
EntityLocation that = (EntityLocation) o;
|
||||
return Float.compare(that.yaw, yaw) == 0 &&
|
||||
Float.compare(that.pitch, pitch) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), yaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import mc.core.world.chunk.ChunkSection;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Location implements Cloneable {
|
||||
@Getter
|
||||
@@ -88,4 +89,20 @@ public class Location implements Cloneable {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Location location = (Location) obj;
|
||||
return Double.compare(location.x, x) == 0 &&
|
||||
Double.compare(location.y, y) == 0 &&
|
||||
Double.compare(location.z, z) == 0 &&
|
||||
Objects.equals(refWorld.get(), location.refWorld.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z, refWorld.get());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user