diff --git a/build.gradle b/build.gradle index 399c0f0..acf965f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id "fabric-loom" version "1.3-SNAPSHOT" + id 'io.github.juuxel.loom-vineflower' version "1.11.0" id "com.modrinth.minotaur" version "2.+" id "com.matthewprenger.cursegradle" version "1.4.0" id "maven-publish" @@ -103,7 +104,7 @@ curseforge { project { id = "440228" - changelog = "A changelog can be found at https://github.com/Grayray75/FPS-Display/blob/${shortMinecraftVersion}/CHANGELOG.md" + changelog = "A changelog can be found at https://github.com/Grayray75/FPS-Display/blob/v3/CHANGELOG.md" releaseType = "release" addGameVersion "${project.minecraft_version}" addGameVersion "Fabric" diff --git a/src/main/java/io/grayray75/mods/fpsdisplay/FpsDisplayMod.java b/src/main/java/io/grayray75/mods/fpsdisplay/FpsDisplayMod.java index ec2ccb1..91b4947 100644 --- a/src/main/java/io/grayray75/mods/fpsdisplay/FpsDisplayMod.java +++ b/src/main/java/io/grayray75/mods/fpsdisplay/FpsDisplayMod.java @@ -41,7 +41,8 @@ public void onInitializeClient() { } if (config.keybindMode == ConfigData.KeyMode.PushToShow) { ShowOverlay = toggleKeybinding.isPressed(); - } else { + } + else { ShowOverlay = config.enabled; } }); diff --git a/src/main/java/io/grayray75/mods/fpsdisplay/FpsHistory.java b/src/main/java/io/grayray75/mods/fpsdisplay/FpsHistory.java index a8618f1..f2f3bd9 100644 --- a/src/main/java/io/grayray75/mods/fpsdisplay/FpsHistory.java +++ b/src/main/java/io/grayray75/mods/fpsdisplay/FpsHistory.java @@ -5,14 +5,14 @@ import java.util.List; public class FpsHistory { - private static final int limit = 1000; + private static final int LIMIT = 420; - private final List list = new ArrayList(); + private final List list = new ArrayList<>(); public void add(int fps) { this.list.add(fps); - if (this.list.size() > 1000) { + if (this.list.size() > LIMIT) { this.list.remove(0); } } diff --git a/src/main/java/io/grayray75/mods/fpsdisplay/config/ModMenuIntegration.java b/src/main/java/io/grayray75/mods/fpsdisplay/config/ModMenuIntegration.java index 8614e04..6a9acac 100644 --- a/src/main/java/io/grayray75/mods/fpsdisplay/config/ModMenuIntegration.java +++ b/src/main/java/io/grayray75/mods/fpsdisplay/config/ModMenuIntegration.java @@ -4,7 +4,6 @@ import com.terraformersmc.modmenu.api.ModMenuApi; import io.grayray75.mods.fpsdisplay.gui.ClothOptionScreen; import io.grayray75.mods.fpsdisplay.gui.FallbackOptionScreen; -import me.shedaniel.autoconfig.AutoConfig; import net.fabricmc.loader.api.FabricLoader; public class ModMenuIntegration implements ModMenuApi { diff --git a/src/main/java/io/grayray75/mods/fpsdisplay/gui/ClothOptionScreen.java b/src/main/java/io/grayray75/mods/fpsdisplay/gui/ClothOptionScreen.java index 9dae408..ba587eb 100644 --- a/src/main/java/io/grayray75/mods/fpsdisplay/gui/ClothOptionScreen.java +++ b/src/main/java/io/grayray75/mods/fpsdisplay/gui/ClothOptionScreen.java @@ -11,7 +11,7 @@ // https://shedaniel.gitbook.io/cloth-config/ public class ClothOptionScreen { - public static Screen generateScreen(Screen parent ){ + public static Screen generateScreen(Screen parent) { ConfigBuilder builder = ConfigBuilder.create(); builder.setParentScreen(parent); builder.setTitle(Text.translatable("text.fpsdisplay.options.title")); diff --git a/src/main/java/io/grayray75/mods/fpsdisplay/mixin/InGameHudMixin.java b/src/main/java/io/grayray75/mods/fpsdisplay/mixin/InGameHudMixin.java index 7a7b739..4ec115a 100644 --- a/src/main/java/io/grayray75/mods/fpsdisplay/mixin/InGameHudMixin.java +++ b/src/main/java/io/grayray75/mods/fpsdisplay/mixin/InGameHudMixin.java @@ -21,12 +21,14 @@ public void render(DrawContext context, float tickDelta, CallbackInfo info) { ConfigData config = ConfigManager.getConfig(); if (!client.options.debugEnabled && config.enabled && config.textAlpha > 3 && FpsDisplayMod.ShowOverlay) { + String text; + if (!config.advancedStats) { + text = ((MinecraftClientAccessor) client).getCurrentFps() + " FPS"; + } + else { + text = String.format("%d FPS (%d min %d avg %d max)", ((MinecraftClientAccessor) client).getCurrentFps(), FpsDisplayMod.FpsHistory.getMinimum(), FpsDisplayMod.FpsHistory.getAverage(), FpsDisplayMod.FpsHistory.getMaximum()); + } - String displayString = String.format("%d FPS (%d min %d avg %d max)", - ((MinecraftClientAccessor) client).getCurrentFps(), - FpsDisplayMod.FpsHistory.getMinimum(), - FpsDisplayMod.FpsHistory.getAverage(), - FpsDisplayMod.FpsHistory.getMaximum()); int textPosX = config.offsetLeft; int textPosY = config.offsetTop; @@ -37,14 +39,14 @@ public void render(DrawContext context, float tickDelta, CallbackInfo info) { } // Prevent text to render outside screenspace - int maxTextPosX = client.getWindow().getScaledWidth() - client.textRenderer.getWidth(displayString); + int maxTextPosX = client.getWindow().getScaledWidth() - client.textRenderer.getWidth(text); int maxTextPosY = client.getWindow().getScaledHeight() - client.textRenderer.fontHeight; textPosX = Math.min(textPosX, maxTextPosX); textPosY = Math.min(textPosY, maxTextPosY); int textColor = ((config.textAlpha & 0xFF) << 24) | config.textColor; - this.renderText(context, client.textRenderer, displayString, textPosX, textPosY, textColor, config.textSize, config.textShadows); + this.renderText(context, client.textRenderer, text, textPosX, textPosY, textColor, config.textSize, config.textShadows); } } @@ -57,7 +59,8 @@ private void renderText(DrawContext context, TextRenderer textRenderer, String t matrixStack.translate(-x, -y, 0); context.drawText(textRenderer, text, x, y, color, shadowed); matrixStack.pop(); - } else { + } + else { context.drawText(textRenderer, text, x, y, color, shadowed); } }