Added Spectator Keyframes and handles them properly in both normal and rendered Replay Paths
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
@@ -8,6 +9,10 @@ public class Position {
|
||||
private double x, y, z;
|
||||
private float pitch, yaw, roll;
|
||||
|
||||
public Position(int entityID) {
|
||||
this(Minecraft.getMinecraft().theWorld.getEntityByID(entityID));
|
||||
}
|
||||
|
||||
public Position(Entity e) {
|
||||
this.x = e.posX;
|
||||
this.y = e.posY;
|
||||
|
||||
@@ -5,10 +5,11 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
public class PositionKeyframe extends Keyframe {
|
||||
|
||||
private Position position;
|
||||
private Integer spectatedEntityID = null;
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new PositionKeyframe(this.getRealTimestamp(), this.getPosition());
|
||||
return new PositionKeyframe(this.getRealTimestamp(), this.getPosition(), this.getSpectatedEntityID());
|
||||
}
|
||||
|
||||
public PositionKeyframe(int realTime, Position position) {
|
||||
@@ -16,12 +17,24 @@ public class PositionKeyframe extends Keyframe {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public PositionKeyframe(int realTime, Position position, int spectatedEntityID) {
|
||||
super(realTime);
|
||||
this.position = position;
|
||||
this.spectatedEntityID = spectatedEntityID;
|
||||
}
|
||||
|
||||
public PositionKeyframe(int realTime, int spectatedEntityID) {
|
||||
this(realTime, new Position(spectatedEntityID), spectatedEntityID);
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Position position) { this.position = position; }
|
||||
|
||||
public Integer getSpectatedEntityID() { return spectatedEntityID; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o2) {
|
||||
if(o2 == null) return false;
|
||||
@@ -35,6 +48,7 @@ public class PositionKeyframe extends Keyframe {
|
||||
return new HashCodeBuilder(17, 37)
|
||||
.append(getPosition())
|
||||
.append(getRealTimestamp())
|
||||
.append(getSpectatedEntityID())
|
||||
.toHashCode();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user