Fixed two similar time keyframes not setting the Replay Speed to 0 sometimes
This commit is contained in:
@@ -113,8 +113,7 @@ public class ReplayMod
|
||||
mc.entityRenderer = new SafeEntityRenderer(mc, mc.entityRenderer);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
boolean auth = false;
|
||||
|
||||
@@ -288,7 +288,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
ReplayHandler.setLastPosition(null);
|
||||
}
|
||||
|
||||
ReplayHandler.setReplayPos((int)time);
|
||||
ReplayHandler.setReplayTime((int)time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,12 +119,12 @@ public class ReplayHandler {
|
||||
return cameraEntity;
|
||||
}
|
||||
|
||||
public static int getDesiredTimestamp() {
|
||||
return replaySender == null ? 0 : (int)replaySender.getDesiredTimestamp();
|
||||
}
|
||||
|
||||
public static int getReplayTime() {
|
||||
if(replaySender != null) {
|
||||
return (int)replaySender.currentTimeStamp();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return replaySender == null ? 0 : (int)replaySender.currentTimeStamp();
|
||||
}
|
||||
|
||||
public static void sortKeyframes() {
|
||||
@@ -279,7 +279,7 @@ public class ReplayHandler {
|
||||
selectKeyframe(null);
|
||||
}
|
||||
|
||||
public static void setReplayPos(int pos) {
|
||||
public static void setReplayTime(int pos) {
|
||||
if(replaySender != null) {
|
||||
replaySender.jumpToTime(pos);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ReplayProcess {
|
||||
if(ts < ReplayHandler.getReplayTime()) {
|
||||
mc.displayGuiScreen((GuiScreen)null);
|
||||
}
|
||||
ReplayHandler.setReplayPos(ts);
|
||||
ReplayHandler.setReplayTime(ts);
|
||||
}
|
||||
|
||||
ChatMessageRequests.addChatMessage("Replay started!", ChatMessageType.INFORMATION);
|
||||
@@ -235,28 +235,33 @@ public class ReplayProcess {
|
||||
int lastTimeStamp = 0;
|
||||
int nextTimeStamp = 0;
|
||||
|
||||
double curSpeed = 0f;
|
||||
double curSpeed = 0;
|
||||
|
||||
if(timeCount > 1 && (nextTime != null || lastTime != null)) {
|
||||
if(nextTime != null) {
|
||||
nextTimeStamp = nextTime.getRealTimestamp();
|
||||
|
||||
if(nextTime != null && lastTime != null && nextTime.getRealTimestamp() == lastTime.getRealTimestamp()) {
|
||||
curSpeed = 0;
|
||||
} else {
|
||||
nextTimeStamp = lastTime.getRealTimestamp();
|
||||
}
|
||||
if(nextTime != null) {
|
||||
nextTimeStamp = nextTime.getRealTimestamp();
|
||||
} else {
|
||||
nextTimeStamp = lastTime.getRealTimestamp();
|
||||
}
|
||||
|
||||
if(lastTime != null) {
|
||||
lastTimeStamp = lastTime.getRealTimestamp();
|
||||
} else {
|
||||
lastTimeStamp = nextTime.getRealTimestamp();
|
||||
}
|
||||
if(lastTime != null) {
|
||||
lastTimeStamp = lastTime.getRealTimestamp();
|
||||
} else {
|
||||
lastTimeStamp = nextTime.getRealTimestamp();
|
||||
}
|
||||
|
||||
if(!(nextTime == null || lastTime == null)) {
|
||||
if(lastTimeStamp == nextTimeStamp) curSpeed = 0f;
|
||||
else curSpeed = ((double)((nextTime.getTimestamp()-lastTime.getTimestamp())))/((double)((nextTimeStamp-lastTimeStamp)));
|
||||
}
|
||||
if(!(nextTime == null || lastTime == null)) {
|
||||
if(lastTimeStamp == nextTimeStamp) curSpeed = 0f;
|
||||
else curSpeed = ((double)((nextTime.getTimestamp()-lastTime.getTimestamp())))/((double)((nextTimeStamp-lastTimeStamp)));
|
||||
}
|
||||
|
||||
if(lastTimeStamp == nextTimeStamp) {
|
||||
curSpeed = 0f;
|
||||
if(lastTimeStamp == nextTimeStamp) {
|
||||
curSpeed = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +307,7 @@ public class ReplayProcess {
|
||||
EnchantmentTimer.increaseRecordingTime((1000/ReplayMod.replaySettings.getVideoFramerate()));
|
||||
}
|
||||
|
||||
if(curPos != null) ReplayHandler.setReplayPos(curPos);
|
||||
if(curPos != null && curPos != ReplayHandler.getDesiredTimestamp()) ReplayHandler.setReplayTime(curPos);
|
||||
|
||||
//splinePos = (index of last entry + add) / total entries
|
||||
|
||||
@@ -331,7 +336,6 @@ public class ReplayProcess {
|
||||
}
|
||||
|
||||
if((splinePos >= 1 || posCount <= 1) && (timePos >= 1 || timeCount <= 1)) {
|
||||
System.out.println(timePos+" | "+timeCount);
|
||||
requestFinish = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public long getDesiredTimestamp() {
|
||||
return desiredTimeStamp;
|
||||
}
|
||||
|
||||
public void jumpToTime(int millis) {
|
||||
setReplaySpeed(replaySpeed);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ReplayFileIO {
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
}
|
||||
|
||||
|
||||
public static List<File> getAllReplayFiles() {
|
||||
List<File> files = new ArrayList<File>();
|
||||
File folder = getReplayFolder();
|
||||
@@ -62,7 +62,7 @@ public class ReplayFileIO {
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
private static DataInputStream getMetaDataInputStream(File replayFile) throws IOException {
|
||||
ZipFile archive = null;
|
||||
|
||||
@@ -179,15 +179,19 @@ public class ReplayFileIO {
|
||||
}
|
||||
|
||||
public static Packet deserializePacket(byte[] bytes) throws InstantiationException, IllegalAccessException, IOException {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
try {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
int i = pb.readVarIntFromBuffer();
|
||||
int i = pb.readVarIntFromBuffer();
|
||||
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
p.readPacketData(pb);
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
p.readPacketData(pb);
|
||||
|
||||
return p;
|
||||
return p;
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] serializePacket(Packet packet) throws IOException {
|
||||
@@ -207,7 +211,7 @@ public class ReplayFileIO {
|
||||
out.writeInt(pd.getByteArray().length);
|
||||
out.write(pd.getByteArray());
|
||||
}
|
||||
|
||||
|
||||
public static int getWrittenByteSize(PacketData pd) {
|
||||
return (2*4)+pd.getByteArray().length;
|
||||
}
|
||||
@@ -261,9 +265,9 @@ public class ReplayFileIO {
|
||||
Pair<Long, DataInputStream> pair = getTempFileInputStream(replayFile);
|
||||
dis = pair.second();
|
||||
long fileLength = pair.first();
|
||||
|
||||
|
||||
raf.setLength(fileLength);
|
||||
|
||||
|
||||
long pointerBefore = fileLength;
|
||||
|
||||
while(dis.available() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user