When setting the last camera position before a time jump, a boolean has to be passed indicating whether that position should be enforced or ignored if it's out of a reasonable distance from the player's position.

This is used by the GuiMarkerTimeline to ensure that jumping to Marker Keyframes actually results in the Marker Keyframe's Position.

The actual code handling Position jumping after Time jumping was moved to the ReplayHandler and is now also called when jumping using the "Please wait" Screen.
This commit is contained in:
CrushedPixel
2015-07-30 11:29:45 +02:00
parent e0a0d9ef53
commit 7bc3574515
5 changed files with 32 additions and 14 deletions

View File

@@ -76,7 +76,8 @@ public class GuiKeyframeTimeline extends GuiTimeline {
} else if(button == 1) {
if(closest != null) {
if(closest.getValue() instanceof AdvancedPosition) {
ReplayHandler.getCameraEntity().moveAbsolute((AdvancedPosition)closest.getValue());
AdvancedPosition pos = (AdvancedPosition)closest.getValue();
ReplayHandler.getCameraEntity().movePath(pos);
} else if(closest.getValue() instanceof TimestampValue) {
ReplayMod.overlay.performJump(((TimestampValue)closest.getValue()).asInt());
}

View File

@@ -66,8 +66,10 @@ public class GuiMarkerTimeline extends GuiTimeline {
} else if(button == 1) {
if(closest != null) {
//Jump to clicked Marker Keyframe
ReplayHandler.setLastPosition(closest.getValue().getPosition());
//Jump to clicked Marker Keyframe (explicitly force to jump to this position)
ReplayHandler.setLastPosition(closest.getValue().getPosition(), true);
//perform the jump, telling the Overlay not to override the last position value
ReplayMod.overlay.performJump(closest.getRealTimestamp(), false);
}
}

View File

@@ -458,9 +458,9 @@ public class GuiReplayOverlay extends Gui {
if(setLastPosition) {
CameraEntity cam = ReplayHandler.getCameraEntity();
if(cam != null) {
ReplayHandler.setLastPosition(new AdvancedPosition(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw));
ReplayHandler.setLastPosition(new AdvancedPosition(cam.posX, cam.posY, cam.posZ, cam.rotationPitch, cam.rotationYaw), false);
} else {
ReplayHandler.setLastPosition(null);
ReplayHandler.setLastPosition(null, false);
}
}
@@ -527,6 +527,9 @@ public class GuiReplayOverlay extends Gui {
e.printStackTrace(); // This should never be thrown but whatever
}
//finally, updating the camera's position (which is not done by the sync jumping)
ReplayHandler.moveCameraToLastPosition();
// No need to remove our please-wait-screen. It'll vanish with the next
// render pass as it's never been a real GuiScreen in the first place.
}

View File

@@ -518,8 +518,27 @@ public class ReplayHandler {
return lastPosition;
}
public static void setLastPosition(AdvancedPosition position) {
@Getter
private static boolean forceLastPosition = false;
public static void setLastPosition(AdvancedPosition position, boolean force) {
lastPosition = position;
forceLastPosition = force;
}
public static void moveCameraToLastPosition() {
//get the camera position we had before jumping in time
AdvancedPosition pos = ReplayHandler.getLastPosition();
CameraEntity cam = ReplayHandler.getCameraEntity();
if (cam != null && pos != null) {
// Move camera back in case we have been respawned, unless we're more than ReplayMod.TP_DISTANCE_LIMIT away from that point
// this is ignored if we explicitly said to respect this position, e.g. when jumping to marker keyframes.
if (ReplayHandler.isForceLastPosition() ||
(Math.abs(pos.getX() - cam.posX) < ReplayMod.TP_DISTANCE_LIMIT &&
Math.abs(pos.getZ() - cam.posZ) < ReplayMod.TP_DISTANCE_LIMIT)) {
cam.moveAbsolute(pos);
}
}
}
public static File getReplayFile() {

View File

@@ -540,14 +540,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
if (isHurrying() && lastTimeStamp > desiredTimeStamp && !startFromBeginning) {
desiredTimeStamp = -1;
AdvancedPosition pos = ReplayHandler.getLastPosition();
CameraEntity cam = ReplayHandler.getCameraEntity();
if (cam != null && pos != null) {
// Move camera back in case we have been respawned
if (Math.abs(pos.getX() - cam.posX) < ReplayMod.TP_DISTANCE_LIMIT && Math.abs(pos.getZ() - cam.posZ) < ReplayMod.TP_DISTANCE_LIMIT) {
cam.moveAbsolute(pos);
}
}
ReplayHandler.moveCameraToLastPosition();
// Pause after jumping
setReplaySpeed(0);