Search in sources :

Example 1 with IMixinGuiPlayerTabOverlay

use of cc.hyperium.mixins.client.gui.IMixinGuiPlayerTabOverlay in project Hyperium by HyperiumClient.

the class HyperiumGuiPlayerTabOverlay method renderPlayerlist.

public void renderPlayerlist(int width, Scoreboard scoreboardIn, ScoreObjective scoreObjectiveIn, Ordering<NetworkPlayerInfo> field_175252_a, IChatComponent header, IChatComponent footer, Minecraft mc) {
    NetHandlerPlayClient nethandlerplayclient = mc.thePlayer.sendQueue;
    List<NetworkPlayerInfo> list = field_175252_a.sortedCopy(nethandlerplayclient.getPlayerInfoMap());
    int i = 0;
    int j = 0;
    for (NetworkPlayerInfo networkplayerinfo : list) {
        int k = mc.fontRendererObj.getStringWidth(parent.getPlayerName(networkplayerinfo));
        if (Settings.SHOW_ONLINE_PLAYERS) {
            k += LevelheadGui.getLevelheadWidth(networkplayerinfo) + mc.fontRendererObj.getStringWidth("⚫");
        } else {
            k += LevelheadGui.getLevelheadWidth(networkplayerinfo);
        }
        i = Math.max(i, k);
        if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreObjectiveCriteria.EnumRenderType.HEARTS) {
            k = mc.fontRendererObj.getStringWidth(" " + scoreboardIn.getValueFromObjective(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
            j = Math.max(j, k);
        }
    }
    list = list.subList(0, Math.min(list.size(), 80));
    if (Settings.FRIENDS_FIRST_IN_TAB) {
        ConcurrentLinkedDeque<NetworkPlayerInfo> friends = new ConcurrentLinkedDeque<>();
        List<UUID> friendUUIDList = HypixelAPI.INSTANCE.getListOfCurrentUsersFriends();
        for (NetworkPlayerInfo networkPlayerInfo : list) {
            UUID id = networkPlayerInfo.getGameProfile().getId();
            if (friendUUIDList.contains(id)) {
                friends.add(networkPlayerInfo);
            }
        }
        list.removeAll(friends);
        friends.addAll(list);
        list.clear();
        list.addAll(friends);
    }
    int l3 = list.size();
    int i4 = l3;
    int j4;
    for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4) {
        ++j4;
    }
    boolean flag = mc.isIntegratedServerRunning() || 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> headerList = null;
    List<String> footerList = null;
    if (header != null) {
        headerList = mc.fontRendererObj.listFormattedStringToWidth(header.getFormattedText(), width - 50);
        for (String s : headerList) {
            l1 = Math.max(l1, mc.fontRendererObj.getStringWidth(s));
        }
    }
    if (footer != null) {
        footerList = mc.fontRendererObj.listFormattedStringToWidth(footer.getFormattedText(), width - 50);
        for (String s2 : footerList) {
            l1 = Math.max(l1, mc.fontRendererObj.getStringWidth(s2));
        }
    }
    if (headerList != null) {
        Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + headerList.size() * mc.fontRendererObj.FONT_HEIGHT, Integer.MIN_VALUE);
        for (String s3 : headerList) {
            int i2 = mc.fontRendererObj.getStringWidth(s3);
            mc.fontRendererObj.drawStringWithShadow(s3, (float) (width / 2 - i2 / 2), (float) k1, -1);
            k1 += mc.fontRendererObj.FONT_HEIGHT;
        }
        ++k1;
    }
    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;
        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(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        if (k4 < list.size()) {
            NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
            String s1 = parent.getPlayerName(networkplayerinfo1);
            GameProfile gameprofile = networkplayerinfo1.getGameProfile();
            if (flag) {
                EntityPlayer entityplayer = mc.theWorld.getPlayerEntityByUUID(gameprofile.getId());
                boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && (gameprofile.getName().equals("Dinnerbone") || gameprofile.getName().equals("Grumm"));
                mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
                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;
            }
            int renderX = j2 + mc.fontRendererObj.getStringWidth(s1) + 2;
            if (Settings.SHOW_ONLINE_PLAYERS) {
                String s = "⚫";
                boolean online = mc.getSession().getProfile().getId() == gameprofile.getId() || Hyperium.INSTANCE.getHandlers().getStatusHandler().isOnline(gameprofile.getId());
                if (StaffUtils.isStaff(gameprofile.getId()) || StaffUtils.isBooster(gameprofile.getId())) {
                    StaffUtils.DotColour colour = StaffUtils.getColor(gameprofile.getId());
                    if (colour.isChroma) {
                        drawChromaWaveString(s, renderX, (k2 - 2));
                    } else {
                        String format = StaffUtils.getColor(gameprofile.getId()).baseColour + s;
                        mc.fontRendererObj.drawString(format, renderX, (k2 - 2), Color.WHITE.getRGB());
                    }
                } else {
                    String format = online ? ChatColor.GREEN + s : ChatColor.RED + s;
                    mc.fontRendererObj.drawString(format, renderX, (k2 - 2), Color.WHITE.getRGB());
                }
            }
            if (networkplayerinfo1.getGameType() == WorldSettings.GameType.SPECTATOR) {
                s1 = EnumChatFormatting.ITALIC + s1;
                mc.fontRendererObj.drawStringWithShadow(s1, (float) j2, (float) k2, -1862270977);
            } else {
                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) {
                    ((IMixinGuiPlayerTabOverlay) parent).callDrawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
                }
            }
            ((IMixinGuiPlayerTabOverlay) parent).callDrawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
        }
    }
    if (footerList != null) {
        k1 = k1 + i4 * 9 + 1;
        Gui.drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + footerList.size() * mc.fontRendererObj.FONT_HEIGHT, Integer.MIN_VALUE);
        for (String s4 : footerList) {
            int j5 = mc.fontRendererObj.getStringWidth(s4);
            mc.fontRendererObj.drawStringWithShadow(s4, (float) (width / 2 - j5 / 2), (float) k1, -1);
            k1 += mc.fontRendererObj.FONT_HEIGHT;
        }
    }
}
Also used : StaffUtils(cc.hyperium.utils.StaffUtils) IMixinGuiPlayerTabOverlay(cc.hyperium.mixins.client.gui.IMixinGuiPlayerTabOverlay) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) NetworkPlayerInfo(net.minecraft.client.network.NetworkPlayerInfo) GameProfile(com.mojang.authlib.GameProfile) NetHandlerPlayClient(net.minecraft.client.network.NetHandlerPlayClient) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UUID(java.util.UUID)

Aggregations

IMixinGuiPlayerTabOverlay (cc.hyperium.mixins.client.gui.IMixinGuiPlayerTabOverlay)1 StaffUtils (cc.hyperium.utils.StaffUtils)1 GameProfile (com.mojang.authlib.GameProfile)1 UUID (java.util.UUID)1 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)1 NetHandlerPlayClient (net.minecraft.client.network.NetHandlerPlayClient)1 NetworkPlayerInfo (net.minecraft.client.network.NetworkPlayerInfo)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1