Last active
October 22, 2022 02:42
-
-
Save adryd325/bab38f4f1eaf2d72dd5276c7e6f3b751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 480c931d0d4f34ed9077189aa0252a7ab8284519 Mon Sep 17 00:00:00 2001 | |
From: adryd <[email protected]> | |
Date: Fri, 21 Oct 2022 22:34:12 -0400 | |
Subject: [PATCH] Add MicroInfo | |
--- | |
build.properties | 3 + | |
.../fi/dy/masa/minihud/config/InfoToggle.java | 3 + | |
.../dy/masa/minihud/event/RenderHandler.java | 77 ++++++++++++++++++- | |
3 files changed, 82 insertions(+), 1 deletion(-) | |
diff --git a/build.properties b/build.properties | |
index dc18496..142366d 100644 | |
--- a/build.properties | |
+++ b/build.properties | |
@@ -18,3 +18,6 @@ mappings_version = 1.19.2+build.1 | |
fabric_loader_version = 0.14.9 | |
mod_menu_version = 4.0.6 | |
+ | |
+# STOP CRASHING | |
+org.gradle.jvmargs=-Xmx1G | |
\ No newline at end of file | |
diff --git a/src/main/java/fi/dy/masa/minihud/config/InfoToggle.java b/src/main/java/fi/dy/masa/minihud/config/InfoToggle.java | |
index 5d0bf85..5b701ba 100644 | |
--- a/src/main/java/fi/dy/masa/minihud/config/InfoToggle.java | |
+++ b/src/main/java/fi/dy/masa/minihud/config/InfoToggle.java | |
@@ -15,6 +15,9 @@ import fi.dy.masa.minihud.MiniHUD; | |
public enum InfoToggle implements IConfigInteger, IHotkeyTogglable | |
{ | |
+ U_INFO_1 ("infoMicroInfo1", false, 0, "", "Shows performance info in as little space as possible"), | |
+ U_INFO_2 ("infoMicroInfo2", false, 1, "", "Shows position info in as little space as possible"), | |
+ U_INFO_1_TPS_COLOR ("infoMicroInfo1TPSColor", false, 1, "", "Shows color with TPS in uInfo1"), | |
BEE_COUNT ("infoBeeCount", false, 36, "", "Show the number of bees in the targeted Hive or Nest.\n§6Note: This only works in single player (without server-side support,\n§6which doesn't exist yet, but will be in the Servux mod at some point)."), | |
BIOME ("infoBiome", false, 19, "", "Show the name of the current biome"), | |
BIOME_REG_NAME ("infoBiomeRegistryName", false, 20, "", "Show the registry name of the current biome"), | |
diff --git a/src/main/java/fi/dy/masa/minihud/event/RenderHandler.java b/src/main/java/fi/dy/masa/minihud/event/RenderHandler.java | |
index b1abb27..ce09e2c 100644 | |
--- a/src/main/java/fi/dy/masa/minihud/event/RenderHandler.java | |
+++ b/src/main/java/fi/dy/masa/minihud/event/RenderHandler.java | |
@@ -122,7 +122,7 @@ public class RenderHandler implements IRenderer | |
(Configs.Generic.REQUIRE_SNEAK.getBooleanValue() == false || this.mc.player.isSneaking()) && | |
Configs.Generic.REQUIRED_KEY.getKeybind().isKeybindHeld()) | |
{ | |
- if (InfoToggle.FPS.getBooleanValue()) | |
+ if (InfoToggle.FPS.getBooleanValue() || InfoToggle.U_INFO_1.getBooleanValue()) | |
{ | |
this.updateFps(); | |
} | |
@@ -296,6 +296,81 @@ public class RenderHandler implements IRenderer | |
{ | |
this.addLine(String.format("%d fps", this.fps)); | |
} | |
+ else if (type == InfoToggle.U_INFO_1) | |
+ { | |
+ try { | |
+ if (mc.isIntegratedServerRunning() && (mc.getServer().getTicks() % 10) == 0) | |
+ { | |
+ this.data.updateIntegratedServerTPS(); | |
+ } | |
+ PlayerListEntry playerInfo = mc.player.networkHandler.getPlayerListEntry(mc.player.getUuid()); | |
+ if (this.data.hasTPSData()) | |
+ { | |
+ double tps = this.data.getServerTPS(); | |
+ double mspt = this.data.getServerMSPT(); | |
+ String hasTPSData = this.data.isCarpetServer() || mc.isInSingleplayer() ? "" : "?"; | |
+ | |
+ String TPSData = String.format("TPS: %.1f%s, MSPT: %.1f%s", tps, hasTPSData, mspt, hasTPSData); | |
+ | |
+ if (InfoToggle.U_INFO_1_TPS_COLOR.getBooleanValue()) { | |
+ // Carpet server and integrated server have actual meaningful MSPT data available | |
+ String rst = GuiBase.TXT_RST; | |
+ String preTps = tps >= 20.0D ? GuiBase.TXT_GREEN : GuiBase.TXT_RED; | |
+ String preMspt; | |
+ | |
+ if (this.data.isCarpetServer() || mc.isInSingleplayer()) { | |
+ if (mspt <= 40) { | |
+ preMspt = GuiBase.TXT_GREEN; | |
+ } else if (mspt <= 45) { | |
+ preMspt = GuiBase.TXT_YELLOW; | |
+ } else if (mspt <= 50) { | |
+ preMspt = GuiBase.TXT_GOLD; | |
+ } else { | |
+ preMspt = GuiBase.TXT_RED; | |
+ } | |
+ | |
+ TPSData = String.format("TPS: %s%.1f%s, MSPT: %s%.1f%s", preTps, tps, rst, preMspt, mspt, rst); | |
+ } else { | |
+ if (mspt <= 51) { | |
+ preMspt = GuiBase.TXT_GREEN; | |
+ } else { | |
+ preMspt = GuiBase.TXT_RED; | |
+ } | |
+ | |
+ TPSData = String.format("TPS: %s%.1f%s?, MSPT: %s%.1f%s?", preTps, tps, rst, preMspt, mspt, rst); | |
+ } | |
+ } | |
+ | |
+ this.addLine(String.format("FPS: %d, %s, Ping: %d", | |
+ this.fps, | |
+ TPSData, | |
+ playerInfo.getLatency())); | |
+ } else { | |
+ this.addLine(String.format("FPS: %d, Ping: %d", | |
+ this.fps, | |
+ playerInfo.getLatency())); | |
+ } | |
+ } catch (Throwable error) { | |
+ error.printStackTrace(); | |
+ } | |
+ } | |
+ else if (type == InfoToggle.U_INFO_2) { | |
+ double x = entity.getX(); | |
+ double z = entity.getZ(); | |
+ double dx = x - entity.lastRenderX; | |
+ double dz = z - entity.lastRenderZ; | |
+ Direction facing = entity.getHorizontalFacing(); | |
+ String direction = "???"; | |
+ switch (facing) | |
+ { | |
+ case NORTH: direction = "-Z (N)"; break; | |
+ case SOUTH: direction = "+Z (S)"; break; | |
+ case WEST: direction = "-X (W)"; break; | |
+ case EAST: direction = "+X (E)"; break; | |
+ default: | |
+ } | |
+ this.addLine(String.format("x: %.2f, y: %.2f, z: %.2f, Speed (XZ): %.2f, Facing: %s", x, y, z, Math.sqrt(dx * dx + dz * dz) * 20, direction)); | |
+ } | |
else if (type == InfoToggle.MEMORY_USAGE) | |
{ | |
long memMax = Runtime.getRuntime().maxMemory(); | |
-- | |
2.38.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment