Minor changes and fixes around tick warping

When warping and frozen the game will now run at 20 (frozen) TPS instead of as fast as possible around a loop

Frozen ticks will no longer count towards tick warping

TPS logger will now display `TPS: 0.0` when the game is frozen
This commit is contained in:
altrisi committed 2023-01-04 20:21:51 +01:00
1 parent 8a3c844b5c
commit cb923fbb67
2 files changed
+12 -11

No files matched your search

+9 -11
View File
@@ -176,6 +176,8 @@ public class TickSpeed
public static boolean continueWarp() public static boolean continueWarp()
{ {
if (!process_entities)
return false;
if (time_bias > 0) if (time_bias > 0)
{ {
if (time_bias == time_warp_scheduled_ticks) //first call after previous tick, adjust start time if (time_bias == time_warp_scheduled_ticks) //first call after previous tick, adjust start time
@@ -194,25 +196,21 @@ public class TickSpeed
public static void tick() public static void tick()
{ {
process_entities = true;
if (player_active_timeout > 0) if (player_active_timeout > 0)
{ {
player_active_timeout--; player_active_timeout--;
} }
if (is_paused) if (is_paused)
{ {
if (player_active_timeout < PLAYER_GRACE) process_entities = player_active_timeout < PLAYER_GRACE;
{
process_entities = false;
}
} }
else if (is_superHot) else if (is_superHot)
{ {
if (player_active_timeout <= 0) process_entities = player_active_timeout <= 0;
{ }
process_entities = false; else
{
} process_entities = true;
} }
} }
//unused - mod compat reasons //unused - mod compat reasons
@@ -227,7 +225,7 @@ public class TickSpeed
tickrate = 1000.0f; tickrate = 1000.0f;
} }
TickSpeed.mspt = (float)mspt; TickSpeed.mspt = mspt;
if (update) notifyTickrateListeners("carpet"); if (update) notifyTickrateListeners("carpet");
} }
@@ -128,6 +128,9 @@ public class HUDController
{ {
double MSPT = Mth.average(server.tickTimes) * 1.0E-6D; double MSPT = Mth.average(server.tickTimes) * 1.0E-6D;
double TPS = 1000.0D / Math.max((TickSpeed.time_warp_start_time != 0)?0.0:TickSpeed.mspt, MSPT); double TPS = 1000.0D / Math.max((TickSpeed.time_warp_start_time != 0)?0.0:TickSpeed.mspt, MSPT);
if (TickSpeed.isPaused()) {
TPS = 0;
}
String color = Messenger.heatmap_color(MSPT,TickSpeed.mspt); String color = Messenger.heatmap_color(MSPT,TickSpeed.mspt);
return new Component[]{Messenger.c( return new Component[]{Messenger.c(
"g TPS: ", String.format(Locale.US, "%s %.1f",color, TPS), "g TPS: ", String.format(Locale.US, "%s %.1f",color, TPS),