Skip to content

Commit

Permalink
ping number
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Mar 16, 2024
1 parent 920ec78 commit a66133f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client/java/autumnvn/autumn/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Options {
public SimpleOption<Boolean> noMineDelay;
public SimpleOption<Boolean> noToast;
public SimpleOption<Boolean> noUseDelay;
public SimpleOption<Boolean> pingNumber;
public SimpleOption<Boolean> rightClickHarvest;
public SimpleOption<Boolean> thirdPersonNoClip;
public SimpleOption<Boolean> visibleBarrier;
Expand Down Expand Up @@ -75,6 +76,8 @@ public Options() {
options.put("noToast", noToast);
noUseDelay = SimpleOption.ofBoolean("No Use Delay", value -> Tooltip.of(Text.of("Remove 4-tick delay when using items")), false);
options.put("noUseDelay", noUseDelay);
pingNumber = SimpleOption.ofBoolean("Ping Number", value -> Tooltip.of(Text.of("Show ping number on tab list")), true);
options.put("pingNumber", pingNumber);
rightClickHarvest = SimpleOption.ofBoolean("Right Click Harvest", value -> Tooltip.of(Text.of("Right click to harvest fully-grown crop & netherwart")), true);
options.put("rightClickHarvest", rightClickHarvest);
thirdPersonNoClip = SimpleOption.ofBoolean("Third Person No Clip", value -> Tooltip.of(Text.of("Let third-person camera clip through blocks")), true);
Expand Down
1 change: 1 addition & 0 deletions src/client/java/autumnvn/autumn/SettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class SettingsScreen extends Screen {
AutumnClient.options.noMineDelay,
AutumnClient.options.noToast,
AutumnClient.options.noUseDelay,
AutumnClient.options.pingNumber,
AutumnClient.options.rightClickHarvest,
AutumnClient.options.thirdPersonNoClip,
AutumnClient.options.visibleBarrier
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package autumnvn.autumn.mixin.client;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import autumnvn.autumn.AutumnClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.PlayerListHud;
import net.minecraft.client.network.PlayerListEntry;

@Mixin(PlayerListHud.class)
public class PlayerListHudMixin {

// PingNumber
@Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true)
private void renderLatencyIcon(DrawContext context, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) {
if (AutumnClient.options.pingNumber.getValue()) {
int ping = entry.getLatency();
context.drawTextWithShadow(AutumnClient.client.textRenderer, ping + "ms", x + AutumnClient.client.textRenderer.getWidth("9999ms") - AutumnClient.client.textRenderer.getWidth(ping + "ms"), y,
ping > 1000 ? 0xaa0000
: ping > 600 ? 0xff5555
: ping > 300 ? 0xffaa00
: ping > 150 ? 0xffff55
: 0x55ff55);
ci.cancel();
}
}
}
1 change: 1 addition & 0 deletions src/client/resources/autumn.client.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"LivingEntityMixin",
"MinecraftClientMixin",
"OptionsScreenMixin",
"PlayerListHudMixin",
"SplashOverlayMixin",
"TitleScreenMixin",
"ToastManagerMixin"
Expand Down

0 comments on commit a66133f

Please sign in to comment.