From bb864a823eb0690dadacd8865b595fe7b839b2c5 Mon Sep 17 00:00:00 2001 From: JustAlittleWolf Date: Wed, 30 Aug 2023 11:52:03 +0200 Subject: [PATCH] Fix displayname style hashing --- .../dev/tr7zw/exordium/mixin/PlayerTabOverlayMixin.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Shared/src/main/java/dev/tr7zw/exordium/mixin/PlayerTabOverlayMixin.java b/Shared/src/main/java/dev/tr7zw/exordium/mixin/PlayerTabOverlayMixin.java index 8beccb5..bef3b20 100644 --- a/Shared/src/main/java/dev/tr7zw/exordium/mixin/PlayerTabOverlayMixin.java +++ b/Shared/src/main/java/dev/tr7zw/exordium/mixin/PlayerTabOverlayMixin.java @@ -8,6 +8,7 @@ import net.minecraft.client.multiplayer.PlayerInfo; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.scores.Objective; import net.minecraft.world.scores.Score; import net.minecraft.world.scores.Scoreboard; @@ -79,16 +80,12 @@ public boolean scoreboardOrObjectiveChanged(Scoreboard scoreboard, Objective obj public int fastGetPlayerInfoListHashCode(List playerInfos) { int hashCode = 1; for (PlayerInfo playerInfo : playerInfos) { + if (playerInfo == null) continue; + int combinedHashes = 0; - if (playerInfo == null) { - hashCode *= 31; - continue; - } combinedHashes += playerInfo.getProfile().getId().hashCode(); if (playerInfo.getTabListDisplayName() != null) { combinedHashes += playerInfo.getTabListDisplayName().getString().hashCode(); - Style displaynameStyle = playerInfo.getTabListDisplayName().getStyle(); - combinedHashes += (displaynameStyle.getColor() == null ? 0 : displaynameStyle.getColor().getValue()) + (displaynameStyle.isBold() ? 1 : 0) + (displaynameStyle.isItalic() ? 3 : 0) + (displaynameStyle.isObfuscated() ? 7 : 0) + (displaynameStyle.isUnderlined() ? 15 : 0) + (displaynameStyle.isStrikethrough() ? 31 : 0); combinedHashes += playerInfo.getTabListDisplayName().getStyle().hashCode(); } combinedHashes += playerInfo.getSkinLocation().hashCode();