mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 10:01:31 +01:00
Fixed Tab
This commit is contained in:
parent
e29cdc2a84
commit
97a4f82df5
@ -1,16 +1,23 @@
|
|||||||
package net.silentclient.client.mixin.mixins;
|
package net.silentclient.client.mixin.mixins;
|
||||||
|
|
||||||
|
import com.google.common.collect.Ordering;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiPlayerTabOverlay;
|
import net.minecraft.client.gui.GuiPlayerTabOverlay;
|
||||||
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
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.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.Client;
|
||||||
import net.silentclient.client.cosmetics.StaticResourceLocation;
|
import net.silentclient.client.cosmetics.StaticResourceLocation;
|
||||||
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
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 net.silentclient.client.utils.Players;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mixin(GuiPlayerTabOverlay.class)
|
@Mixin(GuiPlayerTabOverlay.class)
|
||||||
public class GuiPlayerTabOverlayMixin {
|
public abstract class GuiPlayerTabOverlayMixin {
|
||||||
@Shadow @Final private Minecraft mc;
|
@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))
|
@Shadow @Final private static Ordering<NetworkPlayerInfo> field_175252_a;
|
||||||
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())) {
|
@Shadow public abstract String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn);
|
||||||
return new ArrayList();
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance.listFormattedStringToWidth(str, wrapWidth);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 0))
|
boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getNetHandler().getNetworkManager().getIsencrypted();
|
||||||
public void disableHeaderBackground(int i1, int i2, int i3, int i4, int i5) {
|
int l;
|
||||||
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;
|
if (scoreObjectiveIn != null)
|
||||||
|
{
|
||||||
|
if (scoreObjectiveIn.getRenderType() == IScoreObjectiveCriteria.EnumRenderType.HEARTS)
|
||||||
|
{
|
||||||
|
l = 90;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;listFormattedStringToWidth(Ljava/lang/String;I)Ljava/util/List;", ordinal = 1))
|
if (this.footer != null && !(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Disable Footer").getValBoolean()))
|
||||||
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()) {
|
list2 = this.mc.fontRendererObj.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
||||||
return new ArrayList();
|
|
||||||
|
for (String s2 : list2)
|
||||||
|
{
|
||||||
|
l1 = Math.max(l1, this.mc.fontRendererObj.getStringWidth(s2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance.listFormattedStringToWidth(str, wrapWidth);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 3))
|
for (String s3 : list1)
|
||||||
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())) {
|
int i2 = this.mc.fontRendererObj.getStringWidth(s3);
|
||||||
return;
|
this.mc.fontRendererObj.drawStringWithShadow(s3, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
||||||
|
k1 += this.mc.fontRendererObj.FONT_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
++k1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 1))
|
if(background) {
|
||||||
public void disableBackground1(int i1, int i2, int i3, int i4, int i5) {
|
Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
||||||
if(Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && !Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Background").getValBoolean()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.drawRect(i1, i2, i3, i4, i5);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiPlayerTabOverlay;drawRect(IIIII)V", ordinal = 2))
|
j2 += 9;
|
||||||
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);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "drawPing", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "drawPing", at = @At("HEAD"), cancellable = true)
|
||||||
@ -128,32 +288,4 @@ public class GuiPlayerTabOverlayMixin {
|
|||||||
ci.cancel();
|
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