Added Spectator Keyframes and handles them properly in both normal and rendered Replay Paths

This commit is contained in:
CrushedPixel
2015-05-31 13:54:22 +02:00
parent 431a36c9d9
commit fe036d72d8
8 changed files with 143 additions and 71 deletions

View File

@@ -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;

View File

@@ -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();
}
}