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