Added proper .equals and hashCode methods for Keyframes
This commit is contained in:
@@ -11,4 +11,17 @@ public class Keyframe {
|
||||
public int getRealTimestamp() {
|
||||
return realTimestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof Keyframe)) return false;
|
||||
Keyframe kf = (Keyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return realTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
public class PositionKeyframe extends Keyframe {
|
||||
|
||||
private final Position position;
|
||||
@@ -12,4 +14,20 @@ public class PositionKeyframe extends Keyframe {
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof PositionKeyframe)) return false;
|
||||
PositionKeyframe kf = (PositionKeyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getPosition())
|
||||
.append(getRealTimestamp())
|
||||
.toHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
public class TimeKeyframe extends Keyframe {
|
||||
|
||||
private final int timestamp;
|
||||
@@ -12,4 +14,20 @@ public class TimeKeyframe extends Keyframe {
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
if(!(o2 instanceof TimeKeyframe)) return false;
|
||||
TimeKeyframe kf = (TimeKeyframe)o2;
|
||||
return hashCode() == kf.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getTimestamp())
|
||||
.append(getRealTimestamp())
|
||||
.toHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user