Update GuiPlayerTabOverlayMixin.java

This commit is contained in:
kirillsaint 2023-08-31 17:02:06 +06:00
parent 0b6cfcb95b
commit b68a6906ac

View File

@ -9,6 +9,9 @@ import net.minecraft.client.gui.GuiPlayerTabOverlay;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EnumPlayerModelParts;
@ -62,15 +65,21 @@ public abstract class GuiPlayerTabOverlayMixin {
List<NetworkPlayerInfo> list = field_175252_a.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
int i = 0;
int j = 0;
boolean isSilent = false;
for (NetworkPlayerInfo networkplayerinfo : list)
{
int k = this.mc.fontRendererObj.getStringWidth(this.getPlayerName(networkplayerinfo));
i = Math.max(i, k);
boolean isSilent = false;
try {
EntityPlayer entityplayer = networkplayerinfo.getGameProfile().getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()) ? this.mc.thePlayer : this.mc.theWorld.getPlayerEntityByUUID(networkplayerinfo.getGameProfile().getId());
if(entityplayer != null) {
isSilent = Boolean.parseBoolean(Players.getPlayerStatus(networkplayerinfo.getGameProfile().getName().equalsIgnoreCase(Client.getInstance().getAccount().getUsername()), networkplayerinfo.getGameProfile().getName(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer));
}
} catch (Exception err) {
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreObjectiveCriteria.EnumRenderType.HEARTS)
{
}
int k = this.mc.fontRendererObj.getStringWidth(this.getPlayerName(networkplayerinfo)) + (isSilent && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean() ? 9 : 0);
i = Math.max(i, k);
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreObjectiveCriteria.EnumRenderType.HEARTS) {
k = this.mc.fontRendererObj.getStringWidth(" " + scoreboardIn.getValueFromObjective(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
j = Math.max(j, k);
}
@ -177,31 +186,36 @@ public abstract class GuiPlayerTabOverlayMixin {
if (flag)
{
EntityPlayer entityplayer = this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId());
try {
isSilent = Boolean.parseBoolean(Players.getPlayerStatus(entityplayer == mc.thePlayer, entityplayer.getName().toString(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer)) && Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean();
} catch (Exception e) {
isSilent = false;
}
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && (gameprofile.getName().equals("Dinnerbone") || gameprofile.getName().equals("Grumm"));
if(!isSilent) {
((TextureManagerExt) this.mc.getTextureManager()).waitBindTexture(new StaticResourceLocation(networkplayerinfo1.getLocationSkin().getResourcePath()), new StaticResourceLocation(DefaultPlayerSkin.getDefaultSkinLegacy().getResourcePath()));
int l2 = 8 + (flag1 ? 8 : 0);
int i3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
{
int j3 = 8 + (flag1 ? 8 : 0);
int k3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
}
} else {
this.mc.getTextureManager().bindTexture(((AbstractClientPlayerExt) entityplayer).silent$getPlayerIcon().getLocation());
Gui.drawModalRectWithCustomSizedTexture(j2, k2, 8, 8, 8, 8, 8, 8);
((TextureManagerExt) this.mc.getTextureManager()).waitBindTexture(new StaticResourceLocation(networkplayerinfo1.getLocationSkin().getResourcePath()), new StaticResourceLocation(DefaultPlayerSkin.getDefaultSkinLegacy().getResourcePath()));
int l2 = 8 + (flag1 ? 8 : 0);
int i3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
{
int j3 = 8 + (flag1 ? 8 : 0);
int k3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
}
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;
@ -246,6 +260,21 @@ public abstract class GuiPlayerTabOverlayMixin {
}
}
public void drawModalRectWithCustomSizedTexture(final float x, final float y, final float u, final float v, final float width, final float height, final float textureWidth, final float textureHeight) {
final float f = 1.0f / textureWidth;
final float f2 = 1.0f / textureHeight;
final Tessellator tessellator = Tessellator.getInstance();
final WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(4, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos(x, y + height, 0.0).tex(u * f, (v + height) * f2).endVertex();
worldrenderer.pos(x + width, y + height, 0.0).tex((u + width) * f, (v + height) * f2).endVertex();
worldrenderer.pos(x + width, y, 0.0).tex((u + width) * f, v * f2).endVertex();
worldrenderer.pos(x + width, y, 0.0).tex((u + width) * f, v * f2).endVertex();
worldrenderer.pos(x, y, 0.0).tex(u * f, v * f2).endVertex();
worldrenderer.pos(x, y + height, 0.0).tex(u * f, (v + height) * f2).endVertex();
tessellator.draw();
}
@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()) {