From f88a0c8d6f8f974d20a8885970c56da8dbef21de Mon Sep 17 00:00:00 2001 From: Ethan Chapman Date: Tue, 20 Jul 2021 01:04:12 -0400 Subject: [PATCH 01/18] Update to 1.17 (#5) * Initial 1.17 update Known issue: heads are invisible in tab menu * Update CustomPlayerListHud.java Fix invisible player heads, thanks to IMS#7902 on Discord * Update gradle.properties Remove reference to local Java install --- build.gradle | 7 ++++--- gradle.properties | 8 ++++---- gradle/wrapper/gradle-wrapper.jar | Bin 58694 -> 58910 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 ++ gradlew.bat | 1 + .../hud/CustomPlayerListHud.java | 9 +++++---- src/main/resources/fabric.mod.json | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 8f22a16..411199e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '0.4-SNAPSHOT' + id 'fabric-loom' version '0.9.9' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version @@ -20,6 +20,7 @@ dependencies { processResources { inputs.property "version", project.version + duplicatesStrategy = 'warn' from(sourceSets.main.resources.srcDirs) { include "fabric.mod.json" diff --git a/gradle.properties b/gradle.properties index 751dc5d..a6cff89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16.4 - yarn_mappings=1.16.4+build.6 - loader_version=0.10.6+build.214 + minecraft_version=1.17 + yarn_mappings=1.17+build.13 + loader_version=0.11.3 # Mod Properties mod_version = 1.1.0 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.25.1+build.416-1.16 + fabric_version=0.35.2+1.17 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 490fda8577df6c95960ba7077c43220e5bb2c0d9..62d4c053550b91381bbd28b1afc82d634bf73a8a 100644 GIT binary patch delta 6447 zcmY*dbyQSczlH%shY+L(kQ}C6ise@?c@F%#`dE9xT=qM=Dm?$VxD1hrECD1a#01Q8o zMyT3}z+1K>hPE%4doH=x5X;^NP(OFD5GByp;5FQ^bpzkBa(;eudMu7Iyv$DE+N=>p z{3Y5_BP>F3)tXW*Styc(Ji3jnK-giGA_&42fsbZ@#+e+ly3w0VmLC;LA)h1UY(ChA zfwqQ?-@}@S93F|exOv;Se;P|SrYvEG(8q&|ltqvQHO9KgCSwM!Y+#d5eIRq$Mi`pU__N$FTxW@KAWIw= zayY6@9EyxG<_tr&{Wi87m5*mf=u&=;eL1gf{Mt)q8Drick8CcxzLW>cG~TbW)|$*D zYMc|5eZNNzt7O_C1LqgaI`Z0B+2#;3yO;E7N4oMY@~7$4;MRonU+Ca z#*cD!7$u9pZ|3f!-_6rpN}XhAWd`1qiR{e*1CJK1dvBsjUyY@BuT|;EAz}*0uSwT_ zq(g0jXTAK4wsQ>kIKEfRQZw^GIKNRZmV)b;c*Kpc?IvNuq{+eCM4%IBoRUk!JeJ4IVH!pLl+5gQn^$0Fw(WROw~SclOYWbMmvR+x&lYa zrU`5lck*s2zl;n6HEa_E|Btu!_BeeF8T=~0Z-pdJsKtN8nr88*8loznbI`@@8U-bc zCE&MaHH#?LN;6&wU%>->{X&6n*c6ECkP#Bn{lafo9KW+AKK>>f)YfzG#t`XCsl$WX zeS|50l&G{J6yrdD0#njv3|C}K(~azN%1+c#*-JXtZd=Rs-zr)f{Mneaqpgewz^3OM5FaDaH3?RpqMyL}=5sFu_zcDc^E~=$H zp`mutZ0ahrf32c`6ROBh&lI`>vuFJE*(NVpjr~^d53MZ0v$G#mHqBLpZ_=3?pNjH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L>E3$NPQ$J2r~XGQDNg;Sw=& zC}lz+3@Sq%I2q-97R&9|8Ij2^?^DGQK_oiqZS2$!-rzVqn=~d~TS{n&I+svxt4dWO zT?K0)JEx>9E7saW8h!5+MmAkC`g~v*@ z6VKn0>eZdon>BH(O$mACnxk3D?vSlCFFnvZ#+&hUs)Wr!aP{<@|oc^G>bJk59^xhmz!RA%|K_$o)V`D@gVs>@bSmXVID_PQXp znfja8U01+t3V!o{8ZKi~G@#q$KrAH-Ks3$G{Qo}H|N1ijJMsgZDgOmM1O$Fi0>0CX zpbAzXhYbP@PV;~=*nn7eQGjoT2b9nGFNg-PpHT$a@?7JL7I&pmkmclS7#Y#zRYg_`D0h47O z&|%88tXNh8{Yk$@@*HA-B9r#tDkY$>!U#Ie`j1TupjRn@;(ykyyld-zJ{@qm!UG~I zxR#ZxV8CEi5JXV?ANc~bS9*;MYtkTvifc5iynmg!XpIr%SN*R#E?|3&2QVs~N02d=N!1;GdfNGr)gc$|K#-y*M=Ra9B4#cmk-naoQuS*cWnE3C4 F{|nTN-B$nr diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 622ab64..69a9715 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7..fbd7c51 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 62bd9b9..5093609 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%* set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java index c9a9450..e1eb865 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java @@ -18,6 +18,7 @@ import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; @@ -134,8 +135,8 @@ public final class CustomPlayerListHud { int aa = s + y * r + y * 5; int ab = t + ai * 9; DrawableHelper.fill(stack, aa, ab, aa + r, ab + 8, w); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableAlphaTest(); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); if (x < playerList.size()) { @@ -145,7 +146,7 @@ public final class CustomPlayerListHud { if (displayPlayerIcons) { PlayerEntity playerEntity = mc.world.getPlayerByUuid(gameProfile.getId()); boolean bl2 = playerEntity != null && playerEntity.isPartVisible(PlayerModelPart.CAPE) && ("Dinnerbone".equals(gameProfile.getName()) || "Grumm".equals(gameProfile.getName())); - mc.getTextureManager().bindTexture(player.getSkinTexture()); + RenderSystem.setShaderTexture(0, player.getSkinTexture()); ah = 8 + (bl2 ? 8 : 0); int ad = 8 * (bl2 ? -1 : 1); DrawableHelper.drawTexture(stack, aa, ab, 8, 8, 8.0F, (float)ah, 8, ad, 64, 64); @@ -198,7 +199,7 @@ public final class CustomPlayerListHud { } else { // If we don't render ping bars, we need to reset the render system color so the rest // of the player list renders properly - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); } } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2b2e63c..c32e95a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "depends": { "fabricloader": ">=0.7.4", - "minecraft": "1.16.x" + "minecraft": "1.17.x" }, "suggests": { "flamingo": "*" From e2ea52babbb4ac3cefa8380df6e582ca5b796c70 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Tue, 20 Jul 2021 22:40:19 -0700 Subject: [PATCH 02/18] Update to 1.17.1 --- README.md | 1 + build.gradle | 4 ++-- gradle.properties | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2f43ee8..7a6d520 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ This mod's config file is `betterpingdisplay.json`. It contains the following op ## Supported Minecraft Versions * **1.15.x** * **1.16.x** +* **1.17.x** ## Requirements * [Fabric](https://fabricmc.net/) diff --git a/build.gradle b/build.gradle index 411199e..cf05f7e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ plugins { id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_16 -targetCompatibility = JavaVersion.VERSION_16 +sourceCompatibility = JavaVersion.VERSION_14 +targetCompatibility = JavaVersion.VERSION_14 archivesBaseName = project.archives_base_name version = project.mod_version diff --git a/gradle.properties b/gradle.properties index a6cff89..b115065 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.17 - yarn_mappings=1.17+build.13 - loader_version=0.11.3 + minecraft_version=1.17.1 + yarn_mappings=1.17.1+build.23 + loader_version=0.11.6 # Mod Properties mod_version = 1.1.0 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.35.2+1.17 + fabric_version=0.37.0+1.17 From 6f0cca5cc765747446f9b8913dfc7b2750d0ae57 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Sat, 11 Dec 2021 23:47:54 -0400 Subject: [PATCH 03/18] Update Gradle wrapper version to 7.3 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69a9715..e750102 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 826a8b4b721d2ea64ed0970f21c5788704a7d6a1 Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 12 Dec 2021 19:21:15 -0800 Subject: [PATCH 04/18] Rework mixin to only redirect the renderLatencyIcon method (#6) --- .../hud/CustomPlayerListHud.java | 233 ++---------------- .../hud/PlayerListHudUtil.java | 28 --- .../mixin/InGameHudMixin.java | 20 -- .../mixin/PlayerListHudAccessor.java | 25 -- .../mixin/PlayerListHudInvoker.java | 13 + .../mixin/PlayerListHudMixin.java | 37 +++ .../resources/betterpingdisplay.mixins.json | 24 +- 7 files changed, 81 insertions(+), 299 deletions(-) delete mode 100644 src/main/java/com/vladmarica/betterpingdisplay/hud/PlayerListHudUtil.java delete mode 100644 src/main/java/com/vladmarica/betterpingdisplay/mixin/InGameHudMixin.java delete mode 100644 src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudAccessor.java create mode 100644 src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java create mode 100644 src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java index e1eb865..d4f76d7 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java @@ -1,235 +1,40 @@ package com.vladmarica.betterpingdisplay.hud; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.Ordering; -import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.systems.RenderSystem; -import com.vladmarica.betterpingdisplay.Config; -import com.vladmarica.betterpingdisplay.hud.CustomPlayerListHud.EntryOrderComparator; import com.vladmarica.betterpingdisplay.BetterPingDisplayMod; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import com.vladmarica.betterpingdisplay.Config; +import com.vladmarica.betterpingdisplay.mixin.PlayerListHudInvoker; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.hud.PlayerListHud; -import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.entity.PlayerModelPart; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.scoreboard.ScoreboardCriterion; -import net.minecraft.scoreboard.ScoreboardObjective; -import net.minecraft.scoreboard.Team; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.world.GameMode; public final class CustomPlayerListHud { - - private static final Ordering ENTRY_ORDERING = Ordering.from(new EntryOrderComparator()); private static final int PING_TEXT_RENDER_OFFSET = -13; - private static final int PLAYER_SLOT_EXTRA_WIDTH = 45; - private static final int PLAYER_ICON_WIDTH = 9; private static final int PING_BARS_WIDTH = 11; + private static final Config config = BetterPingDisplayMod.instance().getConfig(); - public static void render(PlayerListHud hud, MatrixStack stack, int width, Scoreboard scoreboard, ScoreboardObjective obj) { - MinecraftClient mc = MinecraftClient.getInstance(); - TextRenderer textRenderer = mc.textRenderer; - Text header = PlayerListHudUtil.getHeader(hud); - Text footer = PlayerListHudUtil.getFooter(hud); - Config config = BetterPingDisplayMod.instance().getConfig(); + public static void render(MinecraftClient client, PlayerListHud hud, MatrixStack matrixStack, int width, int x, int y, PlayerListEntry player) { + TextRenderer textRenderer = client.textRenderer; - ClientPlayNetworkHandler clientPlayNetworkHandler = mc.player.networkHandler; - List playerList = ENTRY_ORDERING.sortedCopy(clientPlayNetworkHandler.getPlayerList()); - int i = 0; - int j = 0; - Iterator playerListIterator = playerList.iterator(); + String pingString = String.format(config.getTextFormatString(), player.getLatency()); + int pingStringWidth = textRenderer.getWidth(pingString); - int n; - while(playerListIterator.hasNext()) { - PlayerListEntry playerListEntry = (PlayerListEntry)playerListIterator.next(); - n = mc.textRenderer.getWidth(hud.getPlayerName(playerListEntry)); - i = Math.max(i, n); - if (obj != null && obj.getRenderType() != ScoreboardCriterion.RenderType.HEARTS) { - n = textRenderer.getWidth(" " + scoreboard.getPlayerScore(playerListEntry.getProfile().getName(), obj).getScore()); - j = Math.max(j, n); - } + int textX = width + x - pingStringWidth + PING_TEXT_RENDER_OFFSET; + + if (!config.shouldRenderPingBars()) { + textX += PING_BARS_WIDTH; } - playerList = playerList.subList(0, Math.min(playerList.size(), 80)); - int l = playerList.size(); - int m = l; - - for(n = 1; m > 20; m = (l + n - 1) / n) { - ++n; - } - - boolean displayPlayerIcons = mc.isInSingleplayer() || mc.getNetworkHandler().getConnection().isEncrypted(); - int q; - if (obj != null) { - if (obj.getRenderType() == ScoreboardCriterion.RenderType.HEARTS) { - q = 90; - } else { - q = j; - } + int pingTextColor = config.shouldAutoColorPingText() ? PingColors.getColor(player.getLatency()) : config.getTextColor(); + textRenderer.drawWithShadow(matrixStack, pingString, (float) textX, (float) y, pingTextColor); + if (config.shouldRenderPingBars()) { + ((PlayerListHudInvoker) hud).renderLatencyText(matrixStack, width, x, y, player); } else { - q = 0; - } - int r = Math.min(n * ((displayPlayerIcons ? PLAYER_ICON_WIDTH : 0) + i + q + 13 + PLAYER_SLOT_EXTRA_WIDTH), width - 50) / n; - int s = width / 2 - (r * n + (n - 1) * 5) / 2; - int t = 10; - int u = r * n + (n - 1) * 5; - List headerLines = null; - if (header != null) { - headerLines = mc.textRenderer.wrapLines(header, width - 50); - - for (OrderedText headerLine : headerLines) { - u = Math.max(u, mc.textRenderer.getWidth(headerLine)); - } - } - - List footerLines = null; - if (footer != null) { - footerLines = mc.textRenderer.wrapLines(footer, width - 50); - - for (OrderedText footerLine : footerLines) { - u = Math.max(u, mc.textRenderer.getWidth(footerLine)); - } - } - - int var10000; - int var10001; - int var10002; - int var10004; - int y; - if (headerLines != null) { - var10000 = width / 2 - u / 2 - 1; - var10001 = t - 1; - var10002 = width / 2 + u / 2 + 1; - var10004 = headerLines.size(); - DrawableHelper.fill(stack, var10000, var10001, var10002, t + var10004 * 9, Integer.MIN_VALUE); - - for (OrderedText headerLine : headerLines) { - y = mc.textRenderer.getWidth(headerLine); - mc.textRenderer.drawWithShadow(stack, headerLine, (float)(width / 2 - y / 2), (float)t, -1); - t += 9; - } - - ++t; - } - - DrawableHelper.fill(stack, width / 2 - u / 2 - 1, t - 1, width / 2 + u / 2 + 1, t + m * 9, Integer.MIN_VALUE); - int w = mc.options.getTextBackgroundColor(553648127); - - int ai; - for(int x = 0; x < l; ++x) { - y = x / m; - ai = x % m; - int aa = s + y * r + y * 5; - int ab = t + ai * 9; - DrawableHelper.fill(stack, aa, ab, aa + r, ab + 8, w); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - if (x < playerList.size()) { - PlayerListEntry player = playerList.get(x); - GameProfile gameProfile = player.getProfile(); - int ah; - if (displayPlayerIcons) { - PlayerEntity playerEntity = mc.world.getPlayerByUuid(gameProfile.getId()); - boolean bl2 = playerEntity != null && playerEntity.isPartVisible(PlayerModelPart.CAPE) && ("Dinnerbone".equals(gameProfile.getName()) || "Grumm".equals(gameProfile.getName())); - RenderSystem.setShaderTexture(0, player.getSkinTexture()); - ah = 8 + (bl2 ? 8 : 0); - int ad = 8 * (bl2 ? -1 : 1); - DrawableHelper.drawTexture(stack, aa, ab, 8, 8, 8.0F, (float)ah, 8, ad, 64, 64); - if (playerEntity != null && playerEntity.isPartVisible(PlayerModelPart.HAT)) { - int ae = 8 + (bl2 ? 8 : 0); - int af = 8 * (bl2 ? -1 : 1); - DrawableHelper.drawTexture(stack, aa, ab, 8, 8, 40.0F, (float)ae, 8, af, 64, 64); - } - - aa += 9; - } - - Text playerName = hud.getPlayerName(player); - if (player.getGameMode() == GameMode.SPECTATOR) { - mc.textRenderer.drawWithShadow(stack, playerName, (float)aa, (float)ab, -1862270977); - } else { - mc.textRenderer.drawWithShadow(stack, playerName, (float)aa, (float)ab, -1); - } - - if (obj != null && player.getGameMode() != GameMode.SPECTATOR) { - int ag = aa + i + 1; - ah = ag + q; - if (ah - ag > 5) { - PlayerListHudUtil.renderScoreboardObjective(hud, stack, obj, ab, gameProfile.getName(), ag, ah, player); - } - } - - // Here is the magic, rendering the ping text - String pingString = String.format(config.getTextFormatString(), player.getLatency()); - int pingStringWidth = textRenderer.getWidth(pingString); - int textX = r + aa - pingStringWidth + PING_TEXT_RENDER_OFFSET; - - if (displayPlayerIcons) { - textX -= PLAYER_ICON_WIDTH; - } - - if (!config.shouldRenderPingBars()) { - textX += PING_BARS_WIDTH; - } - - int pingTextColor = config.shouldAutoColorPingText() - ? PingColors.getColor(player.getLatency()) - : config.getTextColor(); - - textRenderer.drawWithShadow(stack, pingString, (float) textX, (float) ab, pingTextColor); - - if (config.shouldRenderPingBars()) { - PlayerListHudUtil.renderLatencyIcon( - hud, stack, r, aa - (displayPlayerIcons ? PLAYER_ICON_WIDTH : 0), ab, player); - } else { - // If we don't render ping bars, we need to reset the render system color so the rest - // of the player list renders properly - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - } - } - } - - if (footerLines != null) { - t += m * 9 + 1; - var10000 = width / 2 - u / 2 - 1; - var10001 = t - 1; - var10002 = width / 2 + u / 2 + 1; - var10004 = footerLines.size(); - DrawableHelper.fill(stack, var10000, var10001, var10002, t + var10004 * 9, Integer.MIN_VALUE); - - for (OrderedText footerLine : footerLines) { - ai = textRenderer.getWidth(footerLine); - textRenderer.drawWithShadow(stack, footerLine, (float)(width / 2 - ai / 2), (float)t, -1); - t += 9; - } + // If we don't render ping bars, we need to reset the render system color so the rest + // of the player list renders properly + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); } } - - @Environment(EnvType.CLIENT) - static class EntryOrderComparator implements Comparator { - public int compare(PlayerListEntry p1, PlayerListEntry p2) { - Team team = p1.getScoreboardTeam(); - Team team2 = p2.getScoreboardTeam(); - return ComparisonChain.start() - .compareTrueFirst(p1.getGameMode() != GameMode.SPECTATOR, p2.getGameMode() != GameMode.SPECTATOR) - .compare(team != null ? team.getName() : "", team2 != null ? team2.getName() : "") - .compare(p1.getProfile().getName(), p2.getProfile().getName(), String::compareToIgnoreCase) - .result(); - } - } -} \ No newline at end of file +} diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/PlayerListHudUtil.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/PlayerListHudUtil.java deleted file mode 100644 index fc1ebd5..0000000 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/PlayerListHudUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.vladmarica.betterpingdisplay.hud; - -import com.vladmarica.betterpingdisplay.mixin.PlayerListHudAccessor; -import net.minecraft.client.gui.hud.PlayerListHud; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.scoreboard.ScoreboardObjective; -import net.minecraft.text.Text; - -public class PlayerListHudUtil { - /** Calls {@link net.minecraft.client.gui.hud.PlayerListHud#renderLatencyIcon}. */ - static void renderLatencyIcon(PlayerListHud hud, MatrixStack stack, int x, int offsetX, int y, PlayerListEntry player) { - ((PlayerListHudAccessor) hud).invokeRenderLatencyIcon(stack, x, offsetX, y, player); - } - - /** Calls {@link net.minecraft.client.gui.hud.PlayerListHud#renderScoreboardObjective} */ - static void renderScoreboardObjective(PlayerListHud hud, MatrixStack stack, ScoreboardObjective obj, int i, String str, int j, int k, PlayerListEntry player) { - ((PlayerListHudAccessor) hud).invokeRenderScoreboardObjective(obj, i, str, j, k, player, stack); - } - - static Text getHeader(PlayerListHud hud) { - return ((PlayerListHudAccessor) hud).getHeader(); - } - - static Text getFooter(PlayerListHud hud) { - return ((PlayerListHudAccessor) hud).getFooter(); - } -} diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/InGameHudMixin.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/InGameHudMixin.java deleted file mode 100644 index 4911b83..0000000 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/InGameHudMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.vladmarica.betterpingdisplay.mixin; - -import com.vladmarica.betterpingdisplay.hud.CustomPlayerListHud; -import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.gui.hud.PlayerListHud; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.scoreboard.ScoreboardObjective; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(InGameHud.class) -abstract class InGameHudMixin { - @Redirect(method = "render", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/PlayerListHud;render(Lnet/minecraft/client/util/math/MatrixStack;ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreboardObjective;)V")) - private void render(PlayerListHud hud, MatrixStack stack, int width, Scoreboard scoreboard, ScoreboardObjective objective) { - CustomPlayerListHud.render(hud, stack, width, scoreboard, objective); - } -} diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudAccessor.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudAccessor.java deleted file mode 100644 index 8d5f8d8..0000000 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudAccessor.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.vladmarica.betterpingdisplay.mixin; - -import net.minecraft.client.gui.hud.PlayerListHud; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.scoreboard.ScoreboardObjective; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(PlayerListHud.class) -public interface PlayerListHudAccessor { - @Invoker - void invokeRenderLatencyIcon(MatrixStack stack, int x, int offsetX, int y, PlayerListEntry player); - - @Invoker - void invokeRenderScoreboardObjective(ScoreboardObjective obj, int i, String str, int j, int k, PlayerListEntry player, MatrixStack stack); - - @Accessor("header") - Text getHeader(); - - @Accessor("footer") - Text getFooter(); -} diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java new file mode 100644 index 0000000..91a78f1 --- /dev/null +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java @@ -0,0 +1,13 @@ +package com.vladmarica.betterpingdisplay.mixin; + +import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(PlayerListHud.class) +public interface PlayerListHudInvoker { + @Invoker("renderLatencyIcon") + void renderLatencyText(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); +} diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java new file mode 100644 index 0000000..a7b49bc --- /dev/null +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java @@ -0,0 +1,37 @@ +package com.vladmarica.betterpingdisplay.mixin; + +import com.vladmarica.betterpingdisplay.hud.CustomPlayerListHud; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.PlayerListHud; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.util.math.MatrixStack; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(PlayerListHud.class) +public abstract class PlayerListHudMixin { + @Unique + @Final + private static final int PLAYER_SLOT_EXTRA_WIDTH = 45; + + @Shadow + @Final + private MinecraftClient client; + + @ModifyConstant(method = "render", constant = @Constant(intValue = 13)) + private int on13(int original) { + return original + PLAYER_SLOT_EXTRA_WIDTH; + } + + @Redirect(method = "render", at = @At(value = "INVOKE", target = "net/minecraft/client/gui/hud/PlayerListHud.renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V")) + private void redirectLatencyDrawCall(PlayerListHud instance, MatrixStack matrices, int width, int x, int y, @NotNull PlayerListEntry entry) { + CustomPlayerListHud.render(this.client, instance, matrices, width, x, y, entry); + } +} diff --git a/src/main/resources/betterpingdisplay.mixins.json b/src/main/resources/betterpingdisplay.mixins.json index 45b09ed..0fe092b 100644 --- a/src/main/resources/betterpingdisplay.mixins.json +++ b/src/main/resources/betterpingdisplay.mixins.json @@ -1,15 +1,15 @@ { - "required": true, - "minVersion": "0.8", - "package": "com.vladmarica.betterpingdisplay.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - ], - "client": [ - "InGameHudMixin", - "PlayerListHudAccessor" - ], - "injectors": { - "defaultRequire": 1 + "required": true, + "minVersion": "0.8", + "package": "com.vladmarica.betterpingdisplay.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + ], + "client": [ + "PlayerListHudInvoker", + "PlayerListHudMixin" + ], + "injectors": { + "defaultRequire": 1 } } From 514071346a58afccab744b4e4743980d92c9f395 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Mon, 13 Dec 2021 12:21:55 -0400 Subject: [PATCH 05/18] Small code cleanups and Javadoc improvements --- .../BetterPingDisplayMod.java | 2 +- .../vladmarica/betterpingdisplay/Config.java | 18 ++++++++-------- .../betterpingdisplay/hud/ColorUtil.java | 8 ++++++- .../hud/CustomPlayerListHud.java | 10 +++++---- .../betterpingdisplay/hud/PingColors.java | 6 ++++-- .../mixin/PlayerListHudInvoker.java | 2 +- .../mixin/PlayerListHudMixin.java | 21 +++++++++++++++---- .../betterpingdisplay/hud/ColorUtilTest.java | 1 + 8 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java b/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java index b9b3450..29a4e33 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java @@ -43,7 +43,7 @@ public class BetterPingDisplayMod implements ModInitializer { } public Config getConfig() { - return this.config; + return config; } public static BetterPingDisplayMod instance() { diff --git a/src/main/java/com/vladmarica/betterpingdisplay/Config.java b/src/main/java/com/vladmarica/betterpingdisplay/Config.java index 3b65a9f..90373a8 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/Config.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/Config.java @@ -13,15 +13,15 @@ public class Config { private static final int DEFAULT_PING_TEXT_COLOR = 0xA0A0A0; private static final String DEFAULT_PING_TEXT_FORMAT = "%dms"; - private boolean autoColorPingText; - private boolean renderPingBars; + private final boolean autoColorPingText; + private final boolean renderPingBars; private int textColor = DEFAULT_PING_TEXT_COLOR; private String textFormatString = DEFAULT_PING_TEXT_FORMAT; - public Config(ConfigData confileFileFormat) { - if (confileFileFormat.pingTextColor.startsWith("#")) { + public Config(ConfigData configFileFormat) { + if (configFileFormat.pingTextColor.startsWith("#")) { try { - textColor = Integer.parseInt(confileFileFormat.pingTextColor.substring(1), 16); + textColor = Integer.parseInt(configFileFormat.pingTextColor.substring(1), 16); } catch (NumberFormatException ex) { BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); @@ -31,15 +31,15 @@ public class Config { BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); } - if (confileFileFormat.pingTextFormatString.contains("%d")) { - textFormatString = confileFileFormat.pingTextFormatString; + if (configFileFormat.pingTextFormatString.contains("%d")) { + textFormatString = configFileFormat.pingTextFormatString; } else { BetterPingDisplayMod.LOGGER.error("Config option 'pingTextFormatString' is invalid - it needs to contain %d"); } - autoColorPingText = confileFileFormat.autoColorPingText; - renderPingBars = confileFileFormat.renderPingBars; + autoColorPingText = configFileFormat.autoColorPingText; + renderPingBars = configFileFormat.renderPingBars; } public Config() { diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java index 599506e..0d2ff9e 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java @@ -1,7 +1,8 @@ package com.vladmarica.betterpingdisplay.hud; -public class ColorUtil { +import com.google.common.annotations.VisibleForTesting; +public final class ColorUtil { public static int interpolate(int colorStart, int colorEnd, float offset) { if (offset < 0 || offset > 1) { throw new IllegalArgumentException("Offset must be between 0.0 and 1.0"); @@ -18,15 +19,20 @@ public class ColorUtil { return (newRed << 16) | (newGreen << 8) | newBlue; } + @VisibleForTesting static int getRed(int color) { return (color >> 16) & 0xFF; } + @VisibleForTesting static int getGreen(int color) { return (color >> 8) & 0xFF; } + @VisibleForTesting static int getBlue(int color) { return color & 0xFF; } + + private ColorUtil() {} } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java index d4f76d7..354bea5 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java @@ -15,22 +15,24 @@ public final class CustomPlayerListHud { private static final int PING_BARS_WIDTH = 11; private static final Config config = BetterPingDisplayMod.instance().getConfig(); - public static void render(MinecraftClient client, PlayerListHud hud, MatrixStack matrixStack, int width, int x, int y, PlayerListEntry player) { + public static void renderPingDisplay( + MinecraftClient client, PlayerListHud hud, MatrixStack matrixStack, int width, int x, int y, PlayerListEntry player) { TextRenderer textRenderer = client.textRenderer; String pingString = String.format(config.getTextFormatString(), player.getLatency()); int pingStringWidth = textRenderer.getWidth(pingString); - + int pingTextColor = config.shouldAutoColorPingText() ? PingColors.getColor(player.getLatency()) : config.getTextColor(); int textX = width + x - pingStringWidth + PING_TEXT_RENDER_OFFSET; if (!config.shouldRenderPingBars()) { textX += PING_BARS_WIDTH; } - int pingTextColor = config.shouldAutoColorPingText() ? PingColors.getColor(player.getLatency()) : config.getTextColor(); + // Draw the ping text for the given player textRenderer.drawWithShadow(matrixStack, pingString, (float) textX, (float) y, pingTextColor); + if (config.shouldRenderPingBars()) { - ((PlayerListHudInvoker) hud).renderLatencyText(matrixStack, width, x, y, player); + ((PlayerListHudInvoker) hud).renderLatencyIcon(matrixStack, width, x, y, player); } else { // If we don't render ping bars, we need to reset the render system color so the rest // of the player list renders properly diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java index e981567..578bc66 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java @@ -2,7 +2,7 @@ package com.vladmarica.betterpingdisplay.hud; import net.minecraft.util.math.MathHelper; -public class PingColors { +public final class PingColors { public static final int PING_START = 0; public static final int PING_MID = 150; public static final int PING_END = 300; @@ -30,8 +30,10 @@ public class PingColors { computeOffset(PING_MID, PING_END, Math.min(ping, PING_END))); } - static float computeOffset(int start, int end, int value) { + private static float computeOffset(int start, int end, int value) { float offset = (value - start) / (float) ( end - start); return MathHelper.clamp(offset, 0.0F, 1.0F); } + + private PingColors() {} } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java index 91a78f1..cb3f85d 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java @@ -9,5 +9,5 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(PlayerListHud.class) public interface PlayerListHudInvoker { @Invoker("renderLatencyIcon") - void renderLatencyText(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); + void renderLatencyIcon(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java index a7b49bc..9df6cad 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java @@ -5,6 +5,8 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ScoreboardObjective; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -25,13 +27,24 @@ public abstract class PlayerListHudMixin { @Final private MinecraftClient client; + /** + * Increases the int constant {@code 13} in the {@link PlayerListHud#render} method by + * {@value #PLAYER_SLOT_EXTRA_WIDTH}. This constant is used to define the width of the "slots" in the player list. + * In order to fit the ping text, this needs to be increased. + */ @ModifyConstant(method = "render", constant = @Constant(intValue = 13)) - private int on13(int original) { + private int modifySlotWidthConstant(int original) { return original + PLAYER_SLOT_EXTRA_WIDTH; } - @Redirect(method = "render", at = @At(value = "INVOKE", target = "net/minecraft/client/gui/hud/PlayerListHud.renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V")) - private void redirectLatencyDrawCall(PlayerListHud instance, MatrixStack matrices, int width, int x, int y, @NotNull PlayerListEntry entry) { - CustomPlayerListHud.render(this.client, instance, matrices, width, x, y, entry); + /** + * Redirects the call to {@code renderLatencyIcon} in {@link PlayerListHud#render} to instead call + * {@link CustomPlayerListHud#renderPingDisplay}. + */ + @Redirect(method = "render", + at = @At(value = "INVOKE", target = "net/minecraft/client/gui/hud/PlayerListHud.renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V")) + private void redirectRenderLatencyIconCall( + PlayerListHud instance, MatrixStack matrices, int width, int x, int y, @NotNull PlayerListEntry entry) { + CustomPlayerListHud.renderPingDisplay(client, instance, matrices, width, x, y, entry); } } diff --git a/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java b/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java index 65a94c0..51c4ab2 100644 --- a/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java +++ b/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java @@ -9,6 +9,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +/** Unit tests for {@link ColorUtil} */ @RunWith(JUnit4.class) public class ColorUtilTest { From 2c96d27145e817d535c751bd031a26987370b803 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Mon, 13 Dec 2021 12:35:33 -0400 Subject: [PATCH 06/18] Fix fabric.mod.json icon path and issues link --- src/main/resources/fabric.mod.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c32e95a..5ec0540 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -10,11 +10,12 @@ ], "contact": { "homepage": "https://github.com/vladmarica/better-ping-display-fabric", - "sources": "https://github.com/vladmarica/better-ping-display-fabric" + "sources": "https://github.com/vladmarica/better-ping-display-fabric", + "issues": "https://github.com/vladmarica/better-ping-display-fabric/issues" }, "license": "MIT", - "icon": "assets/modid/icon.png", + "icon": "assets/betterpingdisplay/icon.png", "environment": "client", "entrypoints": { From 98afb6736c3f985f0625d3d4554632b2caec1bb9 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Mon, 13 Dec 2021 12:37:01 -0400 Subject: [PATCH 07/18] Release v1.1.1 --- gradle.properties | 2 +- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index b115065..f56a028 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.11.6 # Mod Properties - mod_version = 1.1.0 + mod_version = 1.1.1 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5ec0540..997f9cb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "betterpingdisplay", - "version": "1.1", + "version": "1.1.1", "name": "Better Ping Display", "description": "Shows the actual ping number instead of just bars in the player list!", From c18b4c069a84a151b7e28713600b5e26c98a6d82 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Mon, 13 Dec 2021 13:33:38 -0400 Subject: [PATCH 08/18] Port to 1.18 --- build.gradle | 2 +- gradle.properties | 8 ++++---- .../betterpingdisplay/hud/CustomPlayerListHud.java | 2 +- .../betterpingdisplay/mixin/PlayerListHudInvoker.java | 2 +- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index cf05f7e..99fad2c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.9.9' + id 'fabric-loom' version '0.10.64' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index f56a028..a4b89f7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.17.1 - yarn_mappings=1.17.1+build.23 - loader_version=0.11.6 + minecraft_version=1.18.1 + yarn_mappings=1.18.1+build.3 + loader_version=0.12.11 # Mod Properties mod_version = 1.1.1 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.37.0+1.17 + fabric_version=0.44.0+1.18 diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java index 354bea5..ed66ea5 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java @@ -32,7 +32,7 @@ public final class CustomPlayerListHud { textRenderer.drawWithShadow(matrixStack, pingString, (float) textX, (float) y, pingTextColor); if (config.shouldRenderPingBars()) { - ((PlayerListHudInvoker) hud).renderLatencyIcon(matrixStack, width, x, y, player); + ((PlayerListHudInvoker) hud).invokeRenderLatencyIcon(matrixStack, width, x, y, player); } else { // If we don't render ping bars, we need to reset the render system color so the rest // of the player list renders properly diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java index cb3f85d..1b61772 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java @@ -9,5 +9,5 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(PlayerListHud.class) public interface PlayerListHudInvoker { @Invoker("renderLatencyIcon") - void renderLatencyIcon(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); + void invokeRenderLatencyIcon(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 997f9cb..0fcc909 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "depends": { "fabricloader": ">=0.7.4", - "minecraft": "1.17.x" + "minecraft": "1.18.x" }, "suggests": { "flamingo": "*" From 63f1b3632e237a47d3c9509c93b377f6a86c6fbe Mon Sep 17 00:00:00 2001 From: vladmarica Date: Mon, 13 Dec 2021 14:09:02 -0400 Subject: [PATCH 09/18] Update list of supported Minecraft versions to include 1.18 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7a6d520..3b679a9 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This mod's config file is `betterpingdisplay.json`. It contains the following op * **1.15.x** * **1.16.x** * **1.17.x** +* **1.18.x** ## Requirements * [Fabric](https://fabricmc.net/) From 9bc1dcdc51dba5f57e4dd53707a9bc57b7cd7a4e Mon Sep 17 00:00:00 2001 From: vladmarica Date: Sat, 14 May 2022 18:29:34 -0700 Subject: [PATCH 10/18] Update to 1.18.2 --- gradle.properties | 8 ++++---- src/main/resources/fabric.mod.json | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index a4b89f7..9c2eec1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.18.1 - yarn_mappings=1.18.1+build.3 - loader_version=0.12.11 + minecraft_version=1.18.2 + yarn_mappings=1.18.2+build.2 + loader_version=0.13.3 # Mod Properties mod_version = 1.1.1 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.44.0+1.18 + fabric_version=0.48.0+1.18.2 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0fcc909..fe76b03 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,10 +28,8 @@ ], "depends": { - "fabricloader": ">=0.7.4", + "fabricloader": ">=0.12", "minecraft": "1.18.x" }, - "suggests": { - "flamingo": "*" - } + "suggests": {} } From 2f6e31c11bfb9a58499cb32553d6df2c8e94aab9 Mon Sep 17 00:00:00 2001 From: Cloudperry Date: Fri, 10 Jun 2022 03:27:26 +0300 Subject: [PATCH 11/18] Update mappings, loader and Fabric API to 1.19. Update Loom to 0.12-SNAPSHOT (the version most 1.19 mods use). (#14) --- build.gradle | 2 +- gradle.properties | 10 +++++----- src/main/resources/fabric.mod.json | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 99fad2c..0376875 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.10.64' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index 9c2eec1..f1462a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.2 - loader_version=0.13.3 + minecraft_version=1.19 + yarn_mappings=1.19+build.1 + loader_version=0.14.7 # Mod Properties - mod_version = 1.1.1 + mod_version = 1.1.2 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.48.0+1.18.2 + fabric_version=0.55.3+1.19 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fe76b03..53c9cfe 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "betterpingdisplay", - "version": "1.1.1", + "version": "1.1.2", "name": "Better Ping Display", "description": "Shows the actual ping number instead of just bars in the player list!", @@ -28,8 +28,8 @@ ], "depends": { - "fabricloader": ">=0.12", - "minecraft": "1.18.x" + "fabricloader": ">=0.14", + "minecraft": "1.19.x" }, "suggests": {} } From d86e6b8046ffe80312302c332b73772d075d8572 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Thu, 9 Jun 2022 18:43:33 -0700 Subject: [PATCH 12/18] Fix version number --- gradle.properties | 2 +- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index f1462a8..dbc6e6b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.7 # Mod Properties - mod_version = 1.1.2 + mod_version = 1.1.1 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 53c9cfe..c9ad8a7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "betterpingdisplay", - "version": "1.1.2", + "version": "1.1.1", "name": "Better Ping Display", "description": "Shows the actual ping number instead of just bars in the player list!", From 578d42f5ab77d4ba4eafdf3ec7ba74120f0531cf Mon Sep 17 00:00:00 2001 From: vladmarica Date: Tue, 4 Oct 2022 21:56:37 -0700 Subject: [PATCH 13/18] Support Minecraft 1.19.2 --- gradle.properties | 8 ++++---- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index dbc6e6b..ca95ae6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.19 - yarn_mappings=1.19+build.1 - loader_version=0.14.7 + minecraft_version=1.19.2 + yarn_mappings=1.19.2+build.18 + loader_version=0.14.9 # Mod Properties mod_version = 1.1.1 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.55.3+1.19 + fabric_version=0.62.0+1.19.2 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c9ad8a7..79136cf 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "depends": { "fabricloader": ">=0.14", - "minecraft": "1.19.x" + "minecraft": "1.19.2" }, "suggests": {} } From be31620992d734bf8bcabf75b82f047957c92f15 Mon Sep 17 00:00:00 2001 From: Thiago Gebrim <75040244+thiagogebrimm@users.noreply.github.com> Date: Wed, 4 Jan 2023 13:49:49 -0300 Subject: [PATCH 14/18] Update to 1.19.3 (#19) * Update to 1.19.3 Co-authored-by: Vlad Marica --- gradle.properties | 10 +++++----- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index ca95ae6..369dadc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.18 - loader_version=0.14.9 + minecraft_version=1.19.3 + yarn_mappings=1.19.3+build.3 + loader_version=0.14.11 # Mod Properties - mod_version = 1.1.1 + mod_version = 1.1.2 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.62.0+1.19.2 + fabric_version=0.69.0+1.19.3 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 79136cf..bfce271 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "depends": { "fabricloader": ">=0.14", - "minecraft": "1.19.2" + "minecraft": "1.19.3" }, "suggests": {} } From 3d8061954970c1ee3c17a8c4012232bab24dbc65 Mon Sep 17 00:00:00 2001 From: vladmarica Date: Wed, 4 Jan 2023 21:25:57 -0800 Subject: [PATCH 15/18] Drop version back to 1.1.1 in gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 369dadc..0249e34 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.11 # Mod Properties - mod_version = 1.1.2 + mod_version = 1.1.1 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric From 2b12d2cf70925e6c5a78083e9d9282ff585718c2 Mon Sep 17 00:00:00 2001 From: Yuuki Chan Date: Wed, 22 Mar 2023 21:56:15 +0900 Subject: [PATCH 16/18] Updated for 1.19.4 --- README.md | 13 +++++++------ gradle.properties | 18 +++++++++--------- src/main/resources/fabric.mod.json | 11 ++++++----- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3b679a9..da5daee 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,19 @@ This is a client-side mod. The server doesn't need to have it installed. It work ## Configuration This mod's config file is `betterpingdisplay.json`. It contains the following options: -| Option | Default Value | Description | -|---|---|---| -| autoColorPingText | `true` | Whether to color a player's ping based on their latency. E.g, low latency = green, high latency = red | -| renderPingBars | `false` | Whether to also draw the default Minecraft ping bars | -| pingTextColor | `#A0A0A0` | The ping text color to use. Only works whens `autoColorPingText` is false | -| pingTextFormatString | `%dms` | The format string for ping text. Must include a `%d`, which will be replaced dynamically by the actual ping value. +| Option | Default Value | Description | +|----------------------|---------------|--------------------------------------------------------------------------------------------------------------------| +| autoColorPingText | `true` | Whether to color a player's ping based on their latency. E.g, low latency = green, high latency = red | +| renderPingBars | `false` | Whether to also draw the default Minecraft ping bars | +| pingTextColor | `#A0A0A0` | The ping text color to use. Only works whens `autoColorPingText` is false | +| pingTextFormatString | `%dms` | The format string for ping text. Must include a `%d`, which will be replaced dynamically by the actual ping value. | ## Supported Minecraft Versions * **1.15.x** * **1.16.x** * **1.17.x** * **1.18.x** +* **1.19.x** ## Requirements * [Fabric](https://fabricmc.net/) diff --git a/gradle.properties b/gradle.properties index 0249e34..5ee80b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.19.3 - yarn_mappings=1.19.3+build.3 - loader_version=0.14.11 +# check these on https://fabricmc.net/use +minecraft_version=1.19.4 +yarn_mappings=1.19.4+build.1 +loader_version=0.14.17 # Mod Properties - mod_version = 1.1.1 - maven_group = com.vladmarica - archives_base_name = BetterPingDisplay-Fabric +mod_version = 1.1.2 +maven_group = com.vladmarica +archives_base_name = BetterPingDisplay-Fabric # Dependencies - # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.69.0+1.19.3 +# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api +fabric_version=0.76.0+1.19.4 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index bfce271..e9b7af9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -6,12 +6,13 @@ "name": "Better Ping Display", "description": "Shows the actual ping number instead of just bars in the player list!", "authors": [ - "Quintinity" + "Quintinity", + "Yuuki" ], "contact": { - "homepage": "https://github.com/vladmarica/better-ping-display-fabric", - "sources": "https://github.com/vladmarica/better-ping-display-fabric", - "issues": "https://github.com/vladmarica/better-ping-display-fabric/issues" + "homepage": "https://git.raiza.dev/Raiza.dev/better-ping-display-fabric", + "sources": "https://git.raiza.dev/Raiza.dev/better-ping-display-fabric", + "issues": "https://git.raiza.dev/Raiza.dev/better-ping-display-fabric/issues" }, "license": "MIT", @@ -29,7 +30,7 @@ "depends": { "fabricloader": ">=0.14", - "minecraft": "1.19.3" + "minecraft": ">=1.19" }, "suggests": {} } From 0065f53bad9bfd8c831a00e88ac04366138c9c16 Mon Sep 17 00:00:00 2001 From: Yuuki Chan Date: Thu, 8 Jun 2023 14:13:41 +0900 Subject: [PATCH 17/18] Updated for 1.20 --- README.md | 17 +- build.gradle | 15 +- gradle.properties | 10 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../BetterPingDisplayMod.java | 73 ++++---- .../vladmarica/betterpingdisplay/Config.java | 159 +++++++++--------- .../betterpingdisplay/hud/ColorUtil.java | 55 +++--- .../hud/CustomPlayerListHud.java | 50 +++--- .../betterpingdisplay/hud/PingColors.java | 55 +++--- .../mixin/PlayerListHudInvoker.java | 6 +- .../mixin/PlayerListHudMixin.java | 54 +++--- src/main/resources/fabric.mod.json | 2 +- .../betterpingdisplay/hud/ColorUtilTest.java | 2 +- 13 files changed, 241 insertions(+), 259 deletions(-) diff --git a/README.md b/README.md index da5daee..378d900 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Better Ping Display - Fabric Edition -[![](http://cf.way2muchnoise.eu/full_406343_downloads.svg)](https://curseforge.com/minecraft/mc-mods/better-ping-display-fabric) +[![](http://cf.way2muchnoise.eu/full_406343_downloads.svg)](https://curseforge.com/minecraft/mc-mods/better-ping-display-fabric) A [Fabric](https://fabricmc.net/) mod for Minecraft to display each player's ping in the player list as a number. @@ -13,12 +13,12 @@ This is a client-side mod. The server doesn't need to have it installed. It work ## Configuration This mod's config file is `betterpingdisplay.json`. It contains the following options: -| Option | Default Value | Description | -|----------------------|---------------|--------------------------------------------------------------------------------------------------------------------| -| autoColorPingText | `true` | Whether to color a player's ping based on their latency. E.g, low latency = green, high latency = red | -| renderPingBars | `false` | Whether to also draw the default Minecraft ping bars | -| pingTextColor | `#A0A0A0` | The ping text color to use. Only works whens `autoColorPingText` is false | -| pingTextFormatString | `%dms` | The format string for ping text. Must include a `%d`, which will be replaced dynamically by the actual ping value. | +| Option | Default Value | Description | +|---|---|---| +| autoColorPingText | `true` | Whether to color a player's ping based on their latency. E.g, low latency = green, high latency = red | +| renderPingBars | `false` | Whether to also draw the default Minecraft ping bars | +| pingTextColor | `#A0A0A0` | The ping text color to use. Only works whens `autoColorPingText` is false | +| pingTextFormatString | `%dms` | The format string for ping text. Must include a `%d`, which will be replaced dynamically by the actual ping value. ## Supported Minecraft Versions * **1.15.x** @@ -26,6 +26,7 @@ This mod's config file is `betterpingdisplay.json`. It contains the following op * **1.17.x** * **1.18.x** * **1.19.x** +* **1.20** ## Requirements -* [Fabric](https://fabricmc.net/) +* [Fabric](https://fabricmc.net/) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0376875..1230e96 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.2-SNAPSHOT' id 'maven-publish' } @@ -32,18 +32,10 @@ processResources { } } -tasks.withType(JavaCompile) { +tasks.withType(JavaCompile).configureEach { options.encoding = "UTF-8" } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} - jar { from "LICENSE" } @@ -56,9 +48,6 @@ publishing { artifact(remapJar) { builtBy remapJar } - artifact(sourcesJar) { - builtBy remapSourcesJar - } } } diff --git a/gradle.properties b/gradle.properties index 5ee80b0..1240c84 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.17 +minecraft_version=1.20 +yarn_mappings=1.20+build.1 +loader_version=0.14.21 # Mod Properties -mod_version = 1.1.2 +mod_version = 1.1.3 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fabric_version=0.76.0+1.19.4 +fabric_version=0.83.0+1.20 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java b/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java index 29a4e33..012b282 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/BetterPingDisplayMod.java @@ -1,52 +1,53 @@ package com.vladmarica.betterpingdisplay; import com.vladmarica.betterpingdisplay.Config.ConfigData; -import java.io.File; -import java.nio.file.Path; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.io.File; +import java.nio.file.Path; + public class BetterPingDisplayMod implements ModInitializer { - public static final String MODID = "betterpingdisplay"; - public static final Logger LOGGER = LogManager.getLogger(MODID); - private static final String CONFIG_FILE_NAME = MODID + ".json"; - private static BetterPingDisplayMod INSTANCE; + public static final String MODID = "betterpingdisplay"; + public static final Logger LOGGER = LogManager.getLogger(MODID); + private static final String CONFIG_FILE_NAME = MODID + ".json"; + private static BetterPingDisplayMod INSTANCE; - private Config config = new Config(); + private Config config = new Config(); - @Override - public void onInitialize() { - INSTANCE = this; + @Override + public void onInitialize() { + INSTANCE = this; - Path configFilePath = FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME); - File configFile = configFilePath.toFile(); - if (configFile.exists()) { - try { - ConfigData data = Config.loadConfigFile(configFile); - config = new Config(data); - Config.writeConfigFile(configFile, data); - } catch (Exception ex) { - LOGGER.error("Failed to load config file, using default. Error: {}", ex.getMessage()); - } - } else { - try { - LOGGER.warn("Could not find config file, creating a default one"); - Config.writeConfigFile(configFile, new ConfigData()); - } catch (Exception ex) { - LOGGER.error("Failed to write default config file. Error: {}", ex.getMessage()); - } - } + Path configFilePath = FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME); + File configFile = configFilePath.toFile(); + if (configFile.exists()) { + try { + ConfigData data = Config.loadConfigFile(configFile); + config = new Config(data); + Config.writeConfigFile(configFile, data); + } catch (Exception ex) { + LOGGER.error("Failed to load config file, using default. Error: {}", ex.getMessage()); + } + } else { + try { + LOGGER.warn("Could not find config file, creating a default one"); + Config.writeConfigFile(configFile, new ConfigData()); + } catch (Exception ex) { + LOGGER.error("Failed to write default config file. Error: {}", ex.getMessage()); + } + } - LOGGER.info("BetterPingDisplay mod loaded"); - } + LOGGER.info("BetterPingDisplay mod loaded"); + } - public Config getConfig() { - return config; - } + public Config getConfig() { + return config; + } - public static BetterPingDisplayMod instance() { - return INSTANCE; - } + public static BetterPingDisplayMod instance() { + return INSTANCE; + } } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/Config.java b/src/main/java/com/vladmarica/betterpingdisplay/Config.java index 90373a8..9e29cb8 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/Config.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/Config.java @@ -3,103 +3,96 @@ package com.vladmarica.betterpingdisplay; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Serializable; + +import java.io.*; public class Config { - private static final int DEFAULT_PING_TEXT_COLOR = 0xA0A0A0; - private static final String DEFAULT_PING_TEXT_FORMAT = "%dms"; + private static final int DEFAULT_PING_TEXT_COLOR = 0xA0A0A0; + private static final String DEFAULT_PING_TEXT_FORMAT = "%dms"; - private final boolean autoColorPingText; - private final boolean renderPingBars; - private int textColor = DEFAULT_PING_TEXT_COLOR; - private String textFormatString = DEFAULT_PING_TEXT_FORMAT; + private final boolean autoColorPingText; + private final boolean renderPingBars; + private int textColor = DEFAULT_PING_TEXT_COLOR; + private String textFormatString = DEFAULT_PING_TEXT_FORMAT; - public Config(ConfigData configFileFormat) { - if (configFileFormat.pingTextColor.startsWith("#")) { - try { - textColor = Integer.parseInt(configFileFormat.pingTextColor.substring(1), 16); - } - catch (NumberFormatException ex) { - BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); - } - } - else { - BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); + public Config(ConfigData configFileFormat) { + if (configFileFormat.pingTextColor.startsWith("#")) { + try { + textColor = Integer.parseInt(configFileFormat.pingTextColor.substring(1), 16); + } catch (NumberFormatException ex) { + BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); + } + } else { + BetterPingDisplayMod.LOGGER.error("Config option 'pingTextColor' is invalid - it must be a hex color code"); + } + + if (configFileFormat.pingTextFormatString.contains("%d")) { + textFormatString = configFileFormat.pingTextFormatString; + } else { + BetterPingDisplayMod.LOGGER.error("Config option 'pingTextFormatString' is invalid - it needs to contain %d"); + } + + autoColorPingText = configFileFormat.autoColorPingText; + renderPingBars = configFileFormat.renderPingBars; } - if (configFileFormat.pingTextFormatString.contains("%d")) { - textFormatString = configFileFormat.pingTextFormatString; - } - else { - BetterPingDisplayMod.LOGGER.error("Config option 'pingTextFormatString' is invalid - it needs to contain %d"); + public Config() { + this(new ConfigData()); } - autoColorPingText = configFileFormat.autoColorPingText; - renderPingBars = configFileFormat.renderPingBars; - } - - public Config() { - this(new ConfigData()); - } - - public int getTextColor() { - return this.textColor; - } - - public String getTextFormatString() { - return this.textFormatString; - } - - public boolean shouldAutoColorPingText() { - return this.autoColorPingText; - } - - public boolean shouldRenderPingBars() { - return this.renderPingBars; - } - - public static ConfigData loadConfigFile(File configFile) throws IOException { - FileReader reader = null; - try { - Gson gson = new Gson(); - reader = new FileReader(configFile); - return gson.fromJson(reader, ConfigData.class); + public int getTextColor() { + return this.textColor; } - finally { - if (reader != null) { - reader.close(); - } + + public String getTextFormatString() { + return this.textFormatString; } - } - public static void writeConfigFile(File configFile, ConfigData data) throws IOException { - FileWriter writer = null; - try { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - writer = new FileWriter(configFile); - writer.write(gson.toJson(data)); - } finally { - if (writer != null) { - writer.close(); - } + public boolean shouldAutoColorPingText() { + return this.autoColorPingText; } - } - public static class ConfigData implements Serializable { - @Expose - private boolean autoColorPingText = true; + public boolean shouldRenderPingBars() { + return this.renderPingBars; + } - @Expose - private boolean renderPingBars = false; + public static ConfigData loadConfigFile(File configFile) throws IOException { + FileReader reader = null; + try { + Gson gson = new Gson(); + reader = new FileReader(configFile); + return gson.fromJson(reader, ConfigData.class); + } finally { + if (reader != null) { + reader.close(); + } + } + } - @Expose - private String pingTextColor = "#A0A0A0"; + public static void writeConfigFile(File configFile, ConfigData data) throws IOException { + FileWriter writer = null; + try { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + writer = new FileWriter(configFile); + writer.write(gson.toJson(data)); + } finally { + if (writer != null) { + writer.close(); + } + } + } - @Expose - private String pingTextFormatString = "%dms"; - } + public static class ConfigData implements Serializable { + @Expose + private boolean autoColorPingText = true; + + @Expose + private boolean renderPingBars = false; + + @Expose + private String pingTextColor = "#A0A0A0"; + + @Expose + private String pingTextFormatString = "%dms"; + } } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java index 0d2ff9e..249ccb7 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/ColorUtil.java @@ -3,36 +3,37 @@ package com.vladmarica.betterpingdisplay.hud; import com.google.common.annotations.VisibleForTesting; public final class ColorUtil { - public static int interpolate(int colorStart, int colorEnd, float offset) { - if (offset < 0 || offset > 1) { - throw new IllegalArgumentException("Offset must be between 0.0 and 1.0"); + public static int interpolate(int colorStart, int colorEnd, float offset) { + if (offset < 0 || offset > 1) { + throw new IllegalArgumentException("Offset must be between 0.0 and 1.0"); + } + + int redDiff = getRed(colorEnd) - getRed(colorStart); + int greenDiff = getGreen(colorEnd) - getGreen(colorStart); + int blueDiff = getBlue(colorEnd) - getBlue(colorStart); + + int newRed = Math.round(getRed(colorStart) + (redDiff * offset)); + int newGreen = Math.round(getGreen(colorStart) + (greenDiff * offset)); + int newBlue = Math.round(getBlue(colorStart) + (blueDiff * offset)); + + return (newRed << 16) | (newGreen << 8) | newBlue; } - int redDiff = getRed(colorEnd) - getRed(colorStart); - int greenDiff = getGreen(colorEnd) - getGreen(colorStart); - int blueDiff = getBlue(colorEnd) - getBlue(colorStart); + @VisibleForTesting + static int getRed(int color) { + return (color >> 16) & 0xFF; + } - int newRed = Math.round(getRed(colorStart) + (redDiff * offset)); - int newGreen = Math.round(getGreen(colorStart) + (greenDiff * offset)); - int newBlue = Math.round(getBlue(colorStart) + (blueDiff * offset)); + @VisibleForTesting + static int getGreen(int color) { + return (color >> 8) & 0xFF; + } - return (newRed << 16) | (newGreen << 8) | newBlue; - } + @VisibleForTesting + static int getBlue(int color) { + return color & 0xFF; + } - @VisibleForTesting - static int getRed(int color) { - return (color >> 16) & 0xFF; - } - - @VisibleForTesting - static int getGreen(int color) { - return (color >> 8) & 0xFF; - } - - @VisibleForTesting - static int getBlue(int color) { - return color & 0xFF; - } - - private ColorUtil() {} + private ColorUtil() { + } } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java index ed66ea5..79d5d2b 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/CustomPlayerListHud.java @@ -5,38 +5,36 @@ import com.vladmarica.betterpingdisplay.BetterPingDisplayMod; import com.vladmarica.betterpingdisplay.Config; import com.vladmarica.betterpingdisplay.mixin.PlayerListHudInvoker; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; public final class CustomPlayerListHud { - private static final int PING_TEXT_RENDER_OFFSET = -13; - private static final int PING_BARS_WIDTH = 11; - private static final Config config = BetterPingDisplayMod.instance().getConfig(); + private static final int PING_TEXT_RENDER_OFFSET = -13; + private static final int PING_BARS_WIDTH = 11; + private static final Config config = BetterPingDisplayMod.instance().getConfig(); - public static void renderPingDisplay( - MinecraftClient client, PlayerListHud hud, MatrixStack matrixStack, int width, int x, int y, PlayerListEntry player) { - TextRenderer textRenderer = client.textRenderer; + public static void renderPingDisplay( + MinecraftClient client, PlayerListHud hud, DrawContext context, int width, int x, int y, PlayerListEntry player) { + String pingString = String.format(config.getTextFormatString(), player.getLatency()); + int pingStringWidth = client.textRenderer.getWidth(pingString); + int pingTextColor = config.shouldAutoColorPingText() + ? PingColors.getColor(player.getLatency()) : config.getTextColor(); + int textX = width + x - pingStringWidth + PING_TEXT_RENDER_OFFSET; - String pingString = String.format(config.getTextFormatString(), player.getLatency()); - int pingStringWidth = textRenderer.getWidth(pingString); - int pingTextColor = config.shouldAutoColorPingText() ? PingColors.getColor(player.getLatency()) : config.getTextColor(); - int textX = width + x - pingStringWidth + PING_TEXT_RENDER_OFFSET; + if (!config.shouldRenderPingBars()) { + textX += PING_BARS_WIDTH; + } - if (!config.shouldRenderPingBars()) { - textX += PING_BARS_WIDTH; + // Draw the ping text for the given player + context.drawTextWithShadow(client.textRenderer, pingString, textX, y, pingTextColor); + + if (config.shouldRenderPingBars()) { + ((PlayerListHudInvoker) hud).invokeRenderLatencyIcon(context, width, x, y, player); + } else { + // If we don't render ping bars, we need to reset the render system color so the rest + // of the player list renders properly + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + } } - - // Draw the ping text for the given player - textRenderer.drawWithShadow(matrixStack, pingString, (float) textX, (float) y, pingTextColor); - - if (config.shouldRenderPingBars()) { - ((PlayerListHudInvoker) hud).invokeRenderLatencyIcon(matrixStack, width, x, y, player); - } else { - // If we don't render ping bars, we need to reset the render system color so the rest - // of the player list renders properly - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - } - } } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java b/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java index 578bc66..a22a09a 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/hud/PingColors.java @@ -3,37 +3,38 @@ package com.vladmarica.betterpingdisplay.hud; import net.minecraft.util.math.MathHelper; public final class PingColors { - public static final int PING_START = 0; - public static final int PING_MID = 150; - public static final int PING_END = 300; + public static final int PING_START = 0; + public static final int PING_MID = 150; + public static final int PING_END = 300; - public static final int COLOR_GREY = 0x535353; - public static final int COLOR_START = 0x00E676; - public static final int COLOR_MID = 0xD6CD30; - public static final int COLOR_END = 0xE53935; + public static final int COLOR_GREY = 0x535353; + public static final int COLOR_START = 0x00E676; + public static final int COLOR_MID = 0xD6CD30; + public static final int COLOR_END = 0xE53935; - public static int getColor(int ping) { - if (ping < PING_START) { - return COLOR_GREY; + public static int getColor(int ping) { + if (ping < PING_START) { + return COLOR_GREY; + } + + if (ping < PING_MID) { + return ColorUtil.interpolate( + COLOR_START, + COLOR_MID, + computeOffset(PING_START, PING_MID, ping)); + } + + return ColorUtil.interpolate( + COLOR_MID, + COLOR_END, + computeOffset(PING_MID, PING_END, Math.min(ping, PING_END))); } - if (ping < PING_MID) { - return ColorUtil.interpolate( - COLOR_START, - COLOR_MID, - computeOffset(PING_START, PING_MID, ping)); + private static float computeOffset(int start, int end, int value) { + float offset = (value - start) / (float) (end - start); + return MathHelper.clamp(offset, 0.0F, 1.0F); } - return ColorUtil.interpolate( - COLOR_MID, - COLOR_END, - computeOffset(PING_MID, PING_END, Math.min(ping, PING_END))); - } - - private static float computeOffset(int start, int end, int value) { - float offset = (value - start) / (float) ( end - start); - return MathHelper.clamp(offset, 0.0F, 1.0F); - } - - private PingColors() {} + private PingColors() { + } } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java index 1b61772..5d57e0c 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudInvoker.java @@ -1,13 +1,13 @@ package com.vladmarica.betterpingdisplay.mixin; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(PlayerListHud.class) public interface PlayerListHudInvoker { - @Invoker("renderLatencyIcon") - void invokeRenderLatencyIcon(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry); + @Invoker("renderLatencyIcon") + void invokeRenderLatencyIcon(DrawContext context, int width, int x, int y, PlayerListEntry entry); } diff --git a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java index 9df6cad..e1612b5 100644 --- a/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java +++ b/src/main/java/com/vladmarica/betterpingdisplay/mixin/PlayerListHudMixin.java @@ -2,11 +2,9 @@ package com.vladmarica.betterpingdisplay.mixin; import com.vladmarica.betterpingdisplay.hud.CustomPlayerListHud; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.scoreboard.ScoreboardObjective; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -19,32 +17,32 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(PlayerListHud.class) public abstract class PlayerListHudMixin { - @Unique - @Final - private static final int PLAYER_SLOT_EXTRA_WIDTH = 45; + @Unique + @Final + private static final int PLAYER_SLOT_EXTRA_WIDTH = 45; - @Shadow - @Final - private MinecraftClient client; + @Shadow + @Final + private MinecraftClient client; - /** - * Increases the int constant {@code 13} in the {@link PlayerListHud#render} method by - * {@value #PLAYER_SLOT_EXTRA_WIDTH}. This constant is used to define the width of the "slots" in the player list. - * In order to fit the ping text, this needs to be increased. - */ - @ModifyConstant(method = "render", constant = @Constant(intValue = 13)) - private int modifySlotWidthConstant(int original) { - return original + PLAYER_SLOT_EXTRA_WIDTH; - } + /** + * Increases the int constant {@code 13} in the {@link PlayerListHud#render} method by + * {@value #PLAYER_SLOT_EXTRA_WIDTH}. This constant is used to define the width of the "slots" in the player list. + * In order to fit the ping text, this needs to be increased. + */ + @ModifyConstant(method = "render", constant = @Constant(intValue = 13)) + private int modifySlotWidthConstant(int original) { + return original + PLAYER_SLOT_EXTRA_WIDTH; + } - /** - * Redirects the call to {@code renderLatencyIcon} in {@link PlayerListHud#render} to instead call - * {@link CustomPlayerListHud#renderPingDisplay}. - */ - @Redirect(method = "render", - at = @At(value = "INVOKE", target = "net/minecraft/client/gui/hud/PlayerListHud.renderLatencyIcon(Lnet/minecraft/client/util/math/MatrixStack;IIILnet/minecraft/client/network/PlayerListEntry;)V")) - private void redirectRenderLatencyIconCall( - PlayerListHud instance, MatrixStack matrices, int width, int x, int y, @NotNull PlayerListEntry entry) { - CustomPlayerListHud.renderPingDisplay(client, instance, matrices, width, x, y, entry); - } + /** + * Redirects the call to {@code renderLatencyIcon} in {@link PlayerListHud#render} to instead call + * {@link CustomPlayerListHud#renderPingDisplay}. + */ + @Redirect(method = "render", + at = @At(value = "INVOKE", target = "net/minecraft/client/gui/hud/PlayerListHud.renderLatencyIcon(Lnet/minecraft/client/gui/DrawContext;IIILnet/minecraft/client/network/PlayerListEntry;)V")) + private void redirectRenderLatencyIconCall( + PlayerListHud instance, DrawContext context, int width, int x, int y, @NotNull PlayerListEntry entry) { + CustomPlayerListHud.renderPingDisplay(client, instance, context, width, x, y, entry); + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e9b7af9..7e3b308 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "betterpingdisplay", - "version": "1.1.1", + "version": "1.1.3", "name": "Better Ping Display", "description": "Shows the actual ping number instead of just bars in the player list!", diff --git a/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java b/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java index 51c4ab2..936717b 100644 --- a/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java +++ b/src/test/java/com/vladmarica/betterpingdisplay/hud/ColorUtilTest.java @@ -46,4 +46,4 @@ public class ColorUtilTest { assertThrows(IllegalArgumentException.class, () -> ColorUtil.interpolate(0, 1, -0.1F)); assertThrows(IllegalArgumentException.class, () -> ColorUtil.interpolate(0, 1, 1.1F)); } -} +} \ No newline at end of file From 99dfb2425855314cf85205d4c516c0dc51fd9be3 Mon Sep 17 00:00:00 2001 From: Yuuki Chan Date: Thu, 15 Jun 2023 13:05:07 +0900 Subject: [PATCH 18/18] Updated for 1.20.1 --- README.md | 2 +- gradle.properties | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 378d900..b365e7a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This mod's config file is `betterpingdisplay.json`. It contains the following op * **1.17.x** * **1.18.x** * **1.19.x** -* **1.20** +* **1.20.x** ## Requirements * [Fabric](https://fabricmc.net/) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1240c84..4d13014 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.20 -yarn_mappings=1.20+build.1 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.1 loader_version=0.14.21 # Mod Properties -mod_version = 1.1.3 +mod_version = 1.1.4 maven_group = com.vladmarica archives_base_name = BetterPingDisplay-Fabric # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fabric_version=0.83.0+1.20 +fabric_version=0.83.0+1.20.1