diff --git a/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java b/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java index 13286efd2..975c242f5 100644 --- a/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java +++ b/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java @@ -63,14 +63,8 @@ public long getRemainingTicks() } @Override - public long getStartTime() + public long getElapsedTime() { - return TickSpeed.time_warp_start_time; - } - - @Override - public long getCurrentTime() - { - return System.nanoTime(); + return System.nanoTime() - TickSpeed.time_warp_start_time; } } diff --git a/src/main/java/carpettisaddition/logging/loggers/tickwarp/MemorizedTickWarpInfo.java b/src/main/java/carpettisaddition/logging/loggers/tickwarp/MemorizedTickWarpInfo.java index b265133c4..8847e582a 100644 --- a/src/main/java/carpettisaddition/logging/loggers/tickwarp/MemorizedTickWarpInfo.java +++ b/src/main/java/carpettisaddition/logging/loggers/tickwarp/MemorizedTickWarpInfo.java @@ -32,7 +32,7 @@ public class MemorizedTickWarpInfo implements TickWarpInfo private final TickWarpInfo delegate; private long totalTicks; private long timeRemaining; - private long startTime; + private long elapsedTime; private boolean recordedSomething = false; private long lastRecordingTime; private ServerCommandSource lastTimeAdvancer; @@ -58,11 +58,11 @@ public void setTimeAdvancer(@Nullable ServerCommandSource timeAdvancer) */ public void recordResultIfsuitable() { - if (this.delegate.getStartTime() != 0) + if (this.delegate.getTotalTicks() != 0) { this.totalTicks = this.delegate.getTotalTicks(); this.timeRemaining = this.delegate.getRemainingTicks(); - this.startTime = this.delegate.getStartTime(); + this.elapsedTime = this.delegate.getElapsedTime(); this.lastTimeAdvancer = this.delegate.getTimeAdvancer(); this.recordedSomething = true; this.lastRecordingTime = System.nanoTime(); @@ -88,9 +88,9 @@ public long getRemainingTicks() } @Override - public long getStartTime() + public long getElapsedTime() { - return this.startTime; + return this.elapsedTime; } @Override @@ -100,12 +100,6 @@ public ServerCommandSource getTimeAdvancer() return this.lastTimeAdvancer; } - @Override - public long getCurrentTime() - { - return this.lastRecordingTime; - } - public boolean hasData() { return this.recordedSomething; diff --git a/src/main/java/carpettisaddition/logging/loggers/tickwarp/TickWarpInfoReader.java b/src/main/java/carpettisaddition/logging/loggers/tickwarp/TickWarpInfoReader.java index 3882d5d0b..3f65db5a4 100644 --- a/src/main/java/carpettisaddition/logging/loggers/tickwarp/TickWarpInfoReader.java +++ b/src/main/java/carpettisaddition/logging/loggers/tickwarp/TickWarpInfoReader.java @@ -30,9 +30,7 @@ public interface TickWarpInfoReader long getRemainingTicks(); - long getStartTime(); - - long getCurrentTime(); + long getElapsedTime(); // ----------------------- utilities methods ----------------------- @@ -43,7 +41,7 @@ default long getCompletedTicks() default double getAverageMSPT() { - double milliSeconds = Math.max(this.getCurrentTime() - this.getStartTime(), 1) / 1e6; + double milliSeconds = Math.max(this.getElapsedTime(), 1) / 1e6; return milliSeconds / this.getCompletedTicks(); } diff --git a/versions/1.20.1/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java b/versions/1.20.1/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java index d91f85173..d68cd46be 100644 --- a/versions/1.20.1/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java +++ b/versions/1.20.1/src/main/java/carpettisaddition/logging/loggers/tickwarp/DefaultTickWarpInfo.java @@ -85,14 +85,14 @@ public long getRemainingTicks() } @Override - public long getStartTime() + public long getElapsedTime() { - return trm().map(ServerTickRateManagerAccessor::getTickWarpStartTime).orElse(0L); - } - - @Override - public long getCurrentTime() - { - return System.nanoTime(); + return trm().map(m -> { + //#if MC >= 12003 + //$$ return m.getTickWarpElapsedTime(); + //#else + return System.nanoTime() - m.getTickWarpStartTime(); + //#endif + }).orElse(0L); } } diff --git a/versions/1.20.4/src/main/java/carpettisaddition/mixins/logger/tickwarp/ServerTickRateManagerAccessor.java b/versions/1.20.4/src/main/java/carpettisaddition/mixins/logger/tickwarp/ServerTickRateManagerAccessor.java index f152c8404..0e0f8ae6c 100644 --- a/versions/1.20.4/src/main/java/carpettisaddition/mixins/logger/tickwarp/ServerTickRateManagerAccessor.java +++ b/versions/1.20.4/src/main/java/carpettisaddition/mixins/logger/tickwarp/ServerTickRateManagerAccessor.java @@ -30,8 +30,8 @@ public interface ServerTickRateManagerAccessor @Accessor(value = "sprintTicks") long getRemainingWarpTicks(); - @Accessor(value = "sprintStartTime") - long getTickWarpStartTime(); + @Accessor(value = "sprintTime") + long getTickWarpElapsedTime(); @Accessor(value = "scheduledSprintTicks") long getScheduledCurrentWarpTicks();