From 110594c70be69279a294eece205ed96b79396a13 Mon Sep 17 00:00:00 2001 From: Exterminate Date: Tue, 10 Feb 2026 18:40:39 +1100 Subject: [PATCH] Fix 1.21.11 ping field --- common/src/main/resources/META-INF/mods.toml | 51 ------------------- .../fabric_1_21_11/EventHandler.java | 7 +++ .../fabric_1_21_11/FunctionCompatibility.java | 7 ++- .../src/main/resources/assets/mpkmod/icon.png | 0 .../src/main/resources/fabric.mod.json | 2 +- 5 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 common/src/main/resources/META-INF/mods.toml delete mode 100644 fabric-1.21.11/src/main/resources/assets/mpkmod/icon.png diff --git a/common/src/main/resources/META-INF/mods.toml b/common/src/main/resources/META-INF/mods.toml deleted file mode 100644 index b9d9570c..00000000 --- a/common/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,51 +0,0 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory -# A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[11,)" #mandatory (26 is current forge version) -# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. -# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="MIT" -# A URL to refer people to when problems occur with this mod -issueTrackerURL="https://github.com/MPKMod/MPKMod2/issues" #optional -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory -# The modid of the mod -modId="mpkmod" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="${version}" #mandatory -# A display name for the mod -displayName="MPK Mod" #mandatory -# A URL to query for updates for this mod. See the JSON update specification -#updateJSONURL="https://raw.githubusercontent.com/kurrycat2004/MpkMod/main/update.json" #optional -# A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="http://example.com/" #optional -# A file name (in the root of the mod JAR) containing a logo for display -logoFile= "mpkmod_logo.png" #optional -# A text field displayed in the mod UI -credits="" #optional -# A text field displayed in the mod UI -authors="kurrycat, Exterminate, Zpiboo" #optional -# The description text for the mod (multi line!) (#mandatory) -description=''' -A Mod that adds some pk features to the game -''' -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. - -#[[dependencies.mpkmod]] #optional -#modId="forge" -#mandatory=true -#versionRange="[11,)" -#ordering="NONE" -#side="BOTH" - -#[[dependencies.mpkmod]] -#modId="minecraft" -#mandatory=true -#versionRange="[1.8.9,)" -#ordering="NONE" -#side="BOTH" \ No newline at end of file diff --git a/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/EventHandler.java b/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/EventHandler.java index 0ceefa5c..330b2190 100644 --- a/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/EventHandler.java +++ b/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/EventHandler.java @@ -18,12 +18,14 @@ import net.minecraft.client.input.KeyEvent; import net.minecraft.client.input.MouseButtonInfo; import net.minecraft.client.multiplayer.ClientPacketListener; +import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.client.player.LocalPlayer; import net.minecraft.util.Util; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import java.util.Map; +import java.util.Optional; public class EventHandler { private static final ButtonMSList timeQueue = new ButtonMSList(); @@ -157,6 +159,11 @@ public void onClientTickEnd(Minecraft mc) { timeQueue.clear(); } + //TODO: Dirty fix for getting the player ping in the right thread + Minecraft.getInstance().getConnection().getListedOnlinePlayers().stream() + .filter(playerInfo -> playerInfo.getProfile().id().equals(Minecraft.getInstance().player.getUUID())) + .findFirst().ifPresent(playerInfo -> FunctionCompatibility.ping = playerInfo.getLatency()); + API.Events.onTickEnd(); } diff --git a/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/FunctionCompatibility.java b/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/FunctionCompatibility.java index 86923e0b..92c7143e 100644 --- a/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/FunctionCompatibility.java +++ b/fabric-1.21.11/src/main/java/io/github/kurrycat/mpkmod/compatibility/fabric_1_21_11/FunctionCompatibility.java @@ -306,9 +306,12 @@ public String getFPS() { return String.valueOf(net.minecraft.client.Minecraft.getInstance().getFps()); } + public static int ping = -1; + public int getPing() { - PlayerInfo info = net.minecraft.client.Minecraft.getInstance().getConnection().getListedOnlinePlayers().stream().filter(playerInfo -> playerInfo.getProfile().id().equals(net.minecraft.client.Minecraft.getInstance().player.getUUID())).findFirst().get(); - return info.getLatency(); + //PlayerInfo info = net.minecraft.client.Minecraft.getInstance().getConnection().getListedOnlinePlayers().stream().filter(playerInfo -> playerInfo.getProfile().id().equals(net.minecraft.client.Minecraft.getInstance().player.getUUID())).findFirst().get(); + //return info.getLatency(); + return ping; } public void displayGuiScreen(MPKGuiScreen screen) { diff --git a/fabric-1.21.11/src/main/resources/assets/mpkmod/icon.png b/fabric-1.21.11/src/main/resources/assets/mpkmod/icon.png deleted file mode 100644 index e69de29b..00000000 diff --git a/fabric-1.21.11/src/main/resources/fabric.mod.json b/fabric-1.21.11/src/main/resources/fabric.mod.json index cd81bc03..a789efc3 100644 --- a/fabric-1.21.11/src/main/resources/fabric.mod.json +++ b/fabric-1.21.11/src/main/resources/fabric.mod.json @@ -15,7 +15,7 @@ "sources": "https://github.com/MPKMod/MPKMod2" }, "license": "MIT", - "icon": "assets/mpkmod/icon.png", + "icon": "mpkmod_logo.png", "environment": "client", "entrypoints": { "main": [