Skip to content

Commit 5ee7a61

Browse files
committed
add Tablist customization
1 parent 6843ae4 commit 5ee7a61

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils;
4343
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
4444
import io.github.axolotlclient.modules.sky.SkyResourceManager;
45+
import io.github.axolotlclient.modules.tablist.Tablist;
4546
import io.github.axolotlclient.modules.tnttime.TntTime;
4647
import io.github.axolotlclient.modules.zoom.Zoom;
4748
import io.github.axolotlclient.util.FeatureDisabler;
@@ -159,6 +160,7 @@ public static void getModules() {
159160
modules.add(Particles.getInstance());
160161
modules.add(ScreenshotUtils.getInstance());
161162
modules.add(BeaconBeam.getInstance());
163+
modules.add(Tablist.getInstance());
162164
}
163165

164166
private static void addExternalModules() {

src/main/java/io/github/axolotlclient/mixin/PlayerListHudMixin.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import com.mojang.blaze3d.systems.RenderSystem;
2727
import io.github.axolotlclient.AxolotlClient;
2828
import io.github.axolotlclient.modules.hypixel.nickhider.NickHider;
29+
import io.github.axolotlclient.modules.tablist.Tablist;
2930
import net.minecraft.client.MinecraftClient;
3031
import net.minecraft.client.font.TextRenderer;
3132
import net.minecraft.client.gui.DrawableHelper;
3233
import net.minecraft.client.gui.hud.PlayerListHud;
3334
import net.minecraft.client.network.PlayerListEntry;
3435
import net.minecraft.client.util.math.MatrixStack;
36+
import net.minecraft.network.ClientConnection;
3537
import net.minecraft.text.MutableText;
3638
import net.minecraft.text.StringVisitable;
3739
import net.minecraft.text.Text;
@@ -41,6 +43,7 @@
4143
import org.spongepowered.asm.mixin.injection.Inject;
4244
import org.spongepowered.asm.mixin.injection.ModifyArg;
4345
import org.spongepowered.asm.mixin.injection.Redirect;
46+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4447
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
4548

4649
@Mixin(PlayerListHud.class)
@@ -56,7 +59,6 @@ public abstract class PlayerListHudMixin {
5659
return instance.getProfile();
5760
}
5861

59-
MinecraftClient client = MinecraftClient.getInstance();
6062
private PlayerListEntry playerListEntry;
6163

6264
@Inject(method = "getPlayerName", at = @At("HEAD"), cancellable = true)
@@ -108,4 +110,27 @@ public abstract class PlayerListHudMixin {
108110
}
109111
return name;
110112
}
113+
114+
@Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true)
115+
private void axolotlclient$numericalPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci){
116+
if(Tablist.getInstance().renderNumericPing(matrices, width, x, y, entry)){
117+
ci.cancel();
118+
}
119+
}
120+
121+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isInSingleplayer()Z"))
122+
private boolean showPlayerHeads$1(MinecraftClient instance) {
123+
if (Tablist.getInstance().showPlayerHeads.get()) {
124+
return instance.isInSingleplayer();
125+
}
126+
return false;
127+
}
128+
129+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;isEncrypted()Z"))
130+
private boolean showPlayerHeads$1(ClientConnection instance) {
131+
if (Tablist.getInstance().showPlayerHeads.get()) {
132+
return instance.isEncrypted();
133+
}
134+
return false;
135+
}
111136
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package io.github.axolotlclient.modules.tablist;
2+
3+
import io.github.axolotlclient.AxolotlClient;
4+
import io.github.axolotlclient.AxolotlClientConfig.Color;
5+
import io.github.axolotlclient.AxolotlClientConfig.options.BooleanOption;
6+
import io.github.axolotlclient.AxolotlClientConfig.options.ColorOption;
7+
import io.github.axolotlclient.AxolotlClientConfig.options.OptionCategory;
8+
import io.github.axolotlclient.modules.AbstractModule;
9+
import io.github.axolotlclient.modules.hud.util.DrawUtil;
10+
import lombok.Getter;
11+
import net.minecraft.client.MinecraftClient;
12+
import net.minecraft.client.network.PlayerListEntry;
13+
import net.minecraft.client.util.math.MatrixStack;
14+
15+
public class Tablist extends AbstractModule {
16+
17+
@Getter
18+
private static final Tablist Instance = new Tablist();
19+
20+
private final BooleanOption numericalPing = new BooleanOption("numericalPing", false);
21+
private final ColorOption pingColor0 = new ColorOption("pingColor0", Color.parse("#FF00FFFF"));
22+
private final ColorOption pingColor1 = new ColorOption("pingColor1", Color.parse("#FF00FF00"));
23+
private final ColorOption pingColor2 = new ColorOption("pingColor2", Color.parse("#FF008800"));
24+
private final ColorOption pingColor3 = new ColorOption("pingColor3", Color.parse("#FFFFFF00"));
25+
private final ColorOption pingColor4 = new ColorOption("pingColor4", Color.parse("#FFFF8800"));
26+
private final ColorOption pingColor5 = new ColorOption("pingColor5", Color.parse("#FFFF0000"));
27+
private final BooleanOption shadow = new BooleanOption("shadow", true);
28+
29+
public BooleanOption showPlayerHeads = new BooleanOption("showPlayerHeads", true);
30+
31+
private final OptionCategory tablist = new OptionCategory("tablist");
32+
33+
@Override
34+
public void init() {
35+
tablist.add(numericalPing, showPlayerHeads, shadow);
36+
tablist.add(pingColor0, pingColor1, pingColor2, pingColor3, pingColor4, pingColor5);
37+
38+
AxolotlClient.CONFIG.rendering.add(tablist);
39+
}
40+
41+
public boolean renderNumericPing(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry){
42+
if(numericalPing.get()){
43+
Color current;
44+
if (entry.getLatency() < 0) {
45+
current = pingColor0.get();
46+
} else if (entry.getLatency() < 150) {
47+
current = pingColor1.get();
48+
} else if (entry.getLatency() < 300) {
49+
current = pingColor2.get();
50+
} else if (entry.getLatency() < 600) {
51+
current = pingColor3.get();
52+
} else if (entry.getLatency() < 1000) {
53+
current = pingColor4.get();
54+
} else {
55+
current = pingColor5.get();
56+
}
57+
58+
DrawUtil.drawString(matrices,
59+
String.valueOf(entry.getLatency()),
60+
x+width - 1 - MinecraftClient.getInstance().textRenderer.getWidth(String.valueOf(entry.getLatency())),
61+
y, current, shadow.get());
62+
return true;
63+
}
64+
return false;
65+
}
66+
}

src/main/resources/assets/axolotlclient/lang/en_us.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
"nickhider": "NickHider",
211211
"nightMode": "Night Mode",
212212
"nightMode.tooltip": "Reduces blue colors.",
213+
"numericalPing": "Numerical Ping",
213214
"off": "Disabled",
214215
"onBWP": "Active on BedWarsPractice",
215216
"onHypixel": "Active on Hypixel",
@@ -228,6 +229,12 @@
228229
"particles.color.tooltip": "The color of the particle. <br>Needs \"Custom Color\" enabled.",
229230
"pasteURL": "Paste URL or ID...",
230231
"perspective": "Perspective",
232+
"pingColor0": "Ping Color (< 0 ms)",
233+
"pingColor1": "Ping Color (< 150 ms)",
234+
"pingColor2": "Ping Color (< 300 ms)",
235+
"pingColor3": "Ping Color (< 600 ms)",
236+
"pingColor4": "Ping Color (< 1000 ms)",
237+
"pingColor5": "Ping Color (> 1000 ms)",
231238
"pinghud": "Ping HUD",
232239
"placeholder": "Placeholder",
233240
"playercounthud": "PlayerCount HUD",
@@ -282,6 +289,7 @@
282289
"showName": "Show Server Name",
283290
"showOwnNametag": "Show Own Nametag",
284291
"showParticle": "Show Particle",
292+
"showPlayerHeads": "Show Player Heads",
285293
"showProtectionLevel": "Show Protection Level",
286294
"showRMB": "Show RMB",
287295
"showS": "Show S",
@@ -306,6 +314,7 @@
306314
"sprinting_pressed": "Sprinting [Key held]",
307315
"sprinting_toggled": "Sprinting [Toggled]",
308316
"strength": "Strength",
317+
"tablist": "Tablist",
309318
"text": "Text",
310319
"textChroma": "Text Chroma",
311320
"textcolor": "Text Color",

0 commit comments

Comments
 (0)