Added proper .equals and hashCode methods for Keyframes

This commit is contained in:
CrushedPixel
2015-05-01 15:45:36 +02:00
parent 6f8a43aa6c
commit 2cccbe424a
4 changed files with 69 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package eu.crushedpixel.replaymod.holders;
import net.minecraft.entity.Entity;
import org.apache.commons.lang3.builder.HashCodeBuilder;
public class Position {
@@ -67,4 +68,23 @@ public class Position {
public String toString() {
return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch;
}
@Override
public boolean equals(Object o2) {
if(o2 == null) return false;
if(!(o2 instanceof Position)) return false;
Position pos2 = (Position)o2;
return hashCode() == pos2.hashCode();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(x)
.append(y)
.append(z)
.append(pitch)
.append(yaw)
.toHashCode();
}
}