From aadc96313266643cc57e4e1d01112c41df0ac8a7 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Tue, 26 Jul 2022 19:49:12 +0800 Subject: asd --- features/hud/index.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'features/hud') diff --git a/features/hud/index.js b/features/hud/index.js index 661509a..bb8d613 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -15,6 +15,9 @@ import { addNotation, numberWithCommas } from "../../utils/numberUtils.js"; const ProcessBuilder = Java.type("java.lang.ProcessBuilder") const Scanner = Java.type("java.util.Scanner") +let OldServerPinger = Java.type("net.minecraft.client.network.OldServerPinger") +let serverPinger = new OldServerPinger() + class Hud extends Feature { constructor() { super() @@ -147,6 +150,15 @@ class Hud extends Feature { this.showLobbyDayOnlyUnder30 = new ToggleSetting("Show Current Lobby Day ONLY WHEN under day 30", "", true, "lobby_day_30", this) this.hudElements.push(this.lobbyDayElement) + this.showPing = new ToggleSetting("Show Current Ping", "(Updates every 30s)", true, "show_ping", this) + this.pingElement = new HudTextElement() + .setText("&6Ping&7> &fLoading...") + .setToggleSetting(this.showPing) + .setLocationSetting(new LocationSetting("Ping Location", "Allows you to edit the location of the ping text", "show_ping_location", this, [10, 100, 1, 1]) + .requires(this.showPing) + .editTempText("&6Ping&7> &c312ms")) + this.hudElements.push(this.pingElement) + let hudStatTypes = { "cata": "Catacombs level + Exp", "totaldeaths": "Total deaths" @@ -258,6 +270,45 @@ class Hud extends Feature { this.registerEvent("renderWorld", this.renderWorld).registeredWhen(() => this.fpsEnabledSetting.getValue() && this.fpsFastSetting.getValue()) this.registerEvent("worldLoad", this.worldLoad) + this.registerStep(false, 30, () => { + if (this.showPing.getValue() && Client.getMinecraft().func_147104_D()) { + let pingNum = Client.getMinecraft().func_147104_D().field_78844_e + + let pingT = "&a" + pingNum + "ms" + if (pingNum > 150) { + pingT = "&e" + pingNum + "ms" + } + if (pingNum > 250) { + pingT = "&c" + pingNum + "ms" + } + + if (pingNum === -1) { + pingT = "Loading..." + } + this.pingElement.setText("&6Ping&7> " + pingT) + + serverPinger[m.ping](Client.getMinecraft().func_147104_D()); + } + }) + this.registerStep(false, 5, () => { + if (this.showPing.getValue() && Client.getMinecraft().func_147104_D()) { + let pingNum = Client.getMinecraft().func_147104_D().field_78844_e + + let pingT = "&a" + pingNum + "ms" + if (pingNum > 150) { + pingT = "&e" + pingNum + "ms" + } + if (pingNum > 250) { + pingT = "&c" + pingNum + "ms" + } + + if (pingNum === -1) { + return; + } + this.pingElement.setText("&6Ping&7> " + pingT) + } + }) + this.petLevels = {} this.petText = "&6Pet&7> &fLoading..." this.petElement.setText(this.petText) @@ -572,6 +623,7 @@ class Hud extends Feature { step_5second() { this.updateHudThingos() + if (!this.soulflowEnabledSetting.getValue()) return if (!Player.getPlayer()) return if (!Player.getInventory()) return -- cgit