From 33d00ed6cc79b11580733d79e001b1764e1126fe Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Thu, 31 Aug 2023 18:13:43 +0600 Subject: [PATCH] Update GuiPlayerTabOverlayMixin.java --- .../mixins/GuiPlayerTabOverlayMixin.java | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java index f57a5c7..c00cd55 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java @@ -183,6 +183,22 @@ public abstract class GuiPlayerTabOverlayMixin { String s1 = this.getPlayerName(networkplayerinfo1); GameProfile gameprofile = networkplayerinfo1.getGameProfile(); + boolean isSilent = false; + try { + EntityPlayer entityplayer = gameprofile.getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()) ? this.mc.thePlayer : this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId()); + if(entityplayer != null) { + isSilent = Boolean.parseBoolean(Players.getPlayerStatus(gameprofile.getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()), gameprofile.getName(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer)); + } + if(isSilent && entityplayer != null && Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean()) { + this.mc.getTextureManager().bindTexture(((AbstractClientPlayerExt) entityplayer).silent$getPlayerIcon().getLocation()); + GlStateManager.color(1.0f, 1.0f, 1.0f); + drawModalRectWithCustomSizedTexture(j2 + 0.5F, k2, 0.0f, 0.0f, 8.0f, 8.0f, 8.0f, 8.0f); + j2 += 9; + } + } catch (Exception err) { + + } + if (flag) { EntityPlayer entityplayer = this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId()); @@ -201,21 +217,6 @@ public abstract class GuiPlayerTabOverlayMixin { j2 += 9; } - boolean isSilent = false; - try { - EntityPlayer entityplayer = gameprofile.getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()) ? this.mc.thePlayer : this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId()); - if(entityplayer != null) { - isSilent = Boolean.parseBoolean(Players.getPlayerStatus(gameprofile.getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()), gameprofile.getName(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer)); - } - if(isSilent && entityplayer != null && Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean()) { - this.mc.getTextureManager().bindTexture(((AbstractClientPlayerExt) entityplayer).silent$getPlayerIcon().getLocation()); - GlStateManager.color(1.0f, 1.0f, 1.0f); - drawModalRectWithCustomSizedTexture((float)(j2 + this.mc.fontRendererObj.getStringWidth(s1)) + 1, k2, 0.0f, 0.0f, 8.0f, 8.0f, 8.0f, 8.0f); - } - } catch (Exception err) { - - } - if (networkplayerinfo1.getGameType() == WorldSettings.GameType.SPECTATOR) { s1 = EnumChatFormatting.ITALIC + s1; @@ -237,7 +238,7 @@ public abstract class GuiPlayerTabOverlayMixin { } } - this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1); + this.drawPing(i1, j2 - (flag ? 9 : 0) - (isSilent && Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean() ? 9 : 0), k2, networkplayerinfo1); } } @@ -256,7 +257,7 @@ public abstract class GuiPlayerTabOverlayMixin { } } } catch(Exception err) { - Client.logger.error("TAB RENDERER ERROR: " + err.getMessage()); + Client.logger.catching(err); } } @@ -275,6 +276,23 @@ public abstract class GuiPlayerTabOverlayMixin { tessellator.draw(); } + private int getPingWidth(NetworkPlayerInfo networkPlayerInfoIn) { + if(!Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Ping Numbers").getValBoolean()) { + return 10; + } + int ping = 0; + EntityPlayer entityplayer = this.mc.theWorld.getPlayerEntityByUUID(networkPlayerInfoIn.getGameProfile().getId()); + if(entityplayer == null || entityplayer != mc.thePlayer) { + ping = networkPlayerInfoIn.getResponseTime(); + } + + if(entityplayer != null && entityplayer == mc.thePlayer) { + ping = Client.getInstance().ping; + } + + return mc.fontRendererObj.getStringWidth(String.valueOf(ping)); + } + @Inject(method = "drawPing", at = @At("HEAD"), cancellable = true) public void numbersPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn, CallbackInfo ci) { if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Ping Numbers").getValBoolean()) {