diff --git a/platform/minecraft/src/main/java/ca/teamdman/sfm/client/screen/ManagerScreen.java b/platform/minecraft/src/main/java/ca/teamdman/sfm/client/screen/ManagerScreen.java index ec8e9f305..2da323725 100644 --- a/platform/minecraft/src/main/java/ca/teamdman/sfm/client/screen/ManagerScreen.java +++ b/platform/minecraft/src/main/java/ca/teamdman/sfm/client/screen/ManagerScreen.java @@ -738,13 +738,13 @@ protected void renderLabels( ); } - // Find the maximum tick time for normalization - Duration peakTickTime = Duration.ZERO; - for (int i = 0; i < menu.tickTimes.length; i++) { - Duration candidate = menu.tickTimes[i]; - if (candidate.compareTo(peakTickTime) > 0) { - peakTickTime = candidate; - } + // Find the maximum tick time for normalization + Duration peakTickTime = Duration.ZERO; + for (int i = 0; i < menu.tickTimes.length; i++) { + Duration candidate = menu.tickTimes[i]; + if (candidate != null && candidate.compareTo(peakTickTime) > 0) { + peakTickTime = candidate; + } } long yMax = Long.max(peakTickTime.toNanos(), 50_000_000); // Start with max at 50 ms but allow it to grow @@ -777,10 +777,11 @@ protected void renderLabels( // Draw lines for each data point bufferbuilder = tesselator.getBuilder(); - bufferbuilder.begin(VertexFormat.Mode.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR); - int mouseTickTimeIndex = -1; - for (int i = 0; i < menu.tickTimes.length; i++) { - long y = menu.tickTimes[i].toNanos(); + bufferbuilder.begin(VertexFormat.Mode.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR); + int mouseTickTimeIndex = -1; + for (int i = 0; i < menu.tickTimes.length; i++) { + Duration tickTime = menu.tickTimes[i]; + long y = tickTime == null ? 0 : tickTime.toNanos(); float normalizedTickTime = y == 0 ? 0 : (float) (Math.log10(y) / Math.log10(yMax)); int plotPosY = plotY + plotHeight - (int) (normalizedTickTime * plotHeight); @@ -811,9 +812,10 @@ protected void renderLabels( // Draw the tick time text var format = new DecimalFormat("0.000"); if (mouseTickTimeIndex != -1) { // We are hovering over the plot - // Draw the tick time text for the hovered point instead of peak - { - long hoveredTickTimeNanoseconds = menu.tickTimes[mouseTickTimeIndex].toNanos(); + // Draw the tick time text for the hovered point instead of peak + { + Duration hoveredTickTime = menu.tickTimes[mouseTickTimeIndex]; + long hoveredTickTimeNanoseconds = hoveredTickTime == null ? 0 : hoveredTickTime.toNanos(); var hoveredTickTimeMilliseconds = hoveredTickTimeNanoseconds / 1_000_000f; String formattedMillis = format.format(hoveredTickTimeMilliseconds); ChatFormatting lagColor = getMillisecondColour(hoveredTickTimeMilliseconds); diff --git a/platform/minecraft/src/main/resources/assets/sfm/template_programs/changelog.sfml b/platform/minecraft/src/main/resources/assets/sfm/template_programs/changelog.sfml index 82627f325..9e4dea072 100644 --- a/platform/minecraft/src/main/resources/assets/sfm/template_programs/changelog.sfml +++ b/platform/minecraft/src/main/resources/assets/sfm/template_programs/changelog.sfml @@ -18,6 +18,7 @@ NAME "Changelog" -- Add copy and paste support to the draw canvas -- Improve draw canvas selection highlight positioning while panning -- Add a draw canvas Done button tooltip for the Shift+Enter shortcut +-- Fix manager screen crash when opening before tick-time history is populated, fixes #535 ---- 4.34.0 ---- -- Update zh_cn localizations, thanks @ZHAY10086 #526