mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 09:01:32 +01:00
Fixed Tab
This commit is contained in:
parent
e29cdc2a84
commit
97a4f82df5
@ -1,16 +1,23 @@
|
||||
package net.silentclient.client.mixin.mixins;
|
||||
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
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.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||
import net.minecraft.scoreboard.IScoreObjectiveCriteria;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.cosmetics.StaticResourceLocation;
|
||||
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
||||
@ -19,71 +26,224 @@ import net.silentclient.client.mods.render.TabMod;
|
||||
import net.silentclient.client.utils.Players;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GuiPlayerTabOverlay.class)
|
||||
public class GuiPlayerTabOverlayMixin {
|
||||
public abstract class GuiPlayerTabOverlayMixin {
|
||||
@Shadow @Final private Minecraft mc;
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;listFormattedStringToWidth(Ljava/lang/String;I)Ljava/util/List;", ordinal = 0))
|
||||
public List<String> disableHeader(FontRenderer instance, String str, int wrapWidth) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && (Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Header").getValBoolean())) {
|
||||
return new ArrayList();
|
||||
@Shadow @Final private static Ordering<NetworkPlayerInfo> field_175252_a;
|
||||
|
||||
@Shadow public abstract String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn);
|
||||
|
||||
@Shadow private IChatComponent header;
|
||||
|
||||
@Shadow private IChatComponent footer;
|
||||
|
||||
@Shadow protected abstract void drawScoreboardValues(ScoreObjective p_175247_1_, int p_175247_2_, String p_175247_3_, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo p_175247_6_);
|
||||
|
||||
@Shadow protected abstract void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn);
|
||||
|
||||
/**
|
||||
* @author kirillsaint
|
||||
* @reason Custom Tab
|
||||
*/
|
||||
@Overwrite
|
||||
public void renderPlayerlist(int width, Scoreboard scoreboardIn, ScoreObjective scoreObjectiveIn)
|
||||
{
|
||||
try {
|
||||
NetHandlerPlayClient nethandlerplayclient = this.mc.thePlayer.sendQueue;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
list = list.subList(0, Math.min(list.size(), 80));
|
||||
int l3 = list.size();
|
||||
int i4 = l3;
|
||||
int j4;
|
||||
|
||||
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
|
||||
{
|
||||
++j4;
|
||||
}
|
||||
|
||||
boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getNetHandler().getNetworkManager().getIsencrypted();
|
||||
int l;
|
||||
|
||||
if (scoreObjectiveIn != null)
|
||||
{
|
||||
if (scoreObjectiveIn.getRenderType() == IScoreObjectiveCriteria.EnumRenderType.HEARTS)
|
||||
{
|
||||
l = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = j;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
l = 0;
|
||||
}
|
||||
|
||||
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
|
||||
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
|
||||
int k1 = 10;
|
||||
int l1 = i1 * j4 + (j4 - 1) * 5;
|
||||
List<String> list1 = null;
|
||||
List<String> list2 = null;
|
||||
|
||||
if (this.header != null && !(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Header").getValBoolean()))
|
||||
{
|
||||
list1 = this.mc.fontRendererObj.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
|
||||
|
||||
for (String s : list1)
|
||||
{
|
||||
l1 = Math.max(l1, this.mc.fontRendererObj.getStringWidth(s));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.footer != null && !(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Footer").getValBoolean()))
|
||||
{
|
||||
list2 = this.mc.fontRendererObj.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
||||
|
||||
for (String s2 : list2)
|
||||
{
|
||||
l1 = Math.max(l1, this.mc.fontRendererObj.getStringWidth(s2));
|
||||
}
|
||||
}
|
||||
|
||||
boolean background = !Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() || Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean();
|
||||
|
||||
if (list1 != null)
|
||||
{
|
||||
if(background) {
|
||||
Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRendererObj.FONT_HEIGHT, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
for (String s3 : list1)
|
||||
{
|
||||
int i2 = this.mc.fontRendererObj.getStringWidth(s3);
|
||||
this.mc.fontRendererObj.drawStringWithShadow(s3, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
||||
k1 += this.mc.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
++k1;
|
||||
}
|
||||
|
||||
if(background) {
|
||||
Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
for (int k4 = 0; k4 < l3; ++k4)
|
||||
{
|
||||
int l4 = k4 / i4;
|
||||
int i5 = k4 % i4;
|
||||
int j2 = j1 + l4 * i1 + l4 * 5;
|
||||
int k2 = k1 + i5 * 9;
|
||||
if(background) {
|
||||
Gui.drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
|
||||
}
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
|
||||
if (k4 < list.size())
|
||||
{
|
||||
NetworkPlayerInfo networkplayerinfo1 = (NetworkPlayerInfo)list.get(k4);
|
||||
String s1 = this.getPlayerName(networkplayerinfo1);
|
||||
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
|
||||
|
||||
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));
|
||||
} 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);
|
||||
}
|
||||
|
||||
j2 += 9;
|
||||
}
|
||||
|
||||
if (networkplayerinfo1.getGameType() == WorldSettings.GameType.SPECTATOR)
|
||||
{
|
||||
s1 = EnumChatFormatting.ITALIC + s1;
|
||||
this.mc.fontRendererObj.drawStringWithShadow(s1, (float)j2, (float)k2, -1862270977);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mc.fontRendererObj.drawStringWithShadow(s1, (float)j2, (float)k2, -1);
|
||||
}
|
||||
|
||||
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != WorldSettings.GameType.SPECTATOR)
|
||||
{
|
||||
int k5 = j2 + i + 1;
|
||||
int l5 = k5 + l;
|
||||
|
||||
if (l5 - k5 > 5)
|
||||
{
|
||||
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
|
||||
}
|
||||
}
|
||||
|
||||
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
|
||||
}
|
||||
}
|
||||
|
||||
if (list2 != null)
|
||||
{
|
||||
k1 = k1 + i4 * 9 + 1;
|
||||
if(background) {
|
||||
Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRendererObj.FONT_HEIGHT, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
for (String s4 : list2)
|
||||
{
|
||||
int j5 = this.mc.fontRendererObj.getStringWidth(s4);
|
||||
this.mc.fontRendererObj.drawStringWithShadow(s4, (float)(width / 2 - j5 / 2), (float)k1, -1);
|
||||
k1 += this.mc.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
}
|
||||
} catch(Exception err) {
|
||||
Client.logger.error("TAB RENDERER ERROR: " + err.getMessage());
|
||||
}
|
||||
|
||||
return instance.listFormattedStringToWidth(str, wrapWidth);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 0))
|
||||
public void disableHeaderBackground(int i1, int i2, int i3, int i4, int i5) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && (Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Header").getValBoolean() || !Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;listFormattedStringToWidth(Ljava/lang/String;I)Ljava/util/List;", ordinal = 1))
|
||||
public List<String> disableFooter(FontRenderer instance, String str, int wrapWidth) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Footer").getValBoolean()) {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
return instance.listFormattedStringToWidth(str, wrapWidth);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 3))
|
||||
public void disableFooterBackground(int i1, int i2, int i3, int i4, int i5) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && (Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Footer").getValBoolean() || !Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 1))
|
||||
public void disableBackground1(int i1, int i2, int i3, int i4, int i5) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && !Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 2))
|
||||
public void disableBackground2(int i1, int i2, int i3, int i4, int i5) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && !Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
||||
}
|
||||
|
||||
@Inject(method = "drawPing", at = @At("HEAD"), cancellable = true)
|
||||
@ -128,32 +288,4 @@ public class GuiPlayerTabOverlayMixin {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V"))
|
||||
public void nametagIcon1(TextureManager instance, ResourceLocation resource) {
|
||||
if(!(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean())) {
|
||||
((TextureManagerExt) instance).waitBindTexture(new StaticResourceLocation(resource.getResourcePath()));
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetworkPlayerInfo;getGameProfile()Lcom/mojang/authlib/GameProfile;"))
|
||||
public GameProfile nametagIcon2(NetworkPlayerInfo instance) {
|
||||
GameProfile gameprofile = instance.getGameProfile();
|
||||
|
||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean() && this.mc.isIntegratedServerRunning() || this.mc.getNetHandler().getNetworkManager().getIsencrypted()) {
|
||||
boolean isSilent;
|
||||
EntityPlayer entityplayer = this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId());
|
||||
try {
|
||||
isSilent = Boolean.parseBoolean(Players.getPlayerStatus(entityplayer == mc.thePlayer, entityplayer.getName().toString(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer));
|
||||
} catch (Exception e) {
|
||||
isSilent = false;
|
||||
}
|
||||
|
||||
if(isSilent && ((AbstractClientPlayerExt) entityplayer).silent$getPlayerIcon() != null) {
|
||||
this.mc.getTextureManager().bindTexture(((AbstractClientPlayerExt) entityplayer).silent$getPlayerIcon().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
return gameprofile;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user