Merge pull request 'Keep server tab names and team formatting; fix player lookups' (#9) from fix-tablist-and-player-lookups into master

Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
2026-09-25 12:01:39 +00:00
9 changed files with 201 additions and 153 deletions
+1 -1
Submodule common updated: 2cfd93c197...9e3bf14ffa
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.name(); String name = profile.name();
UUID uuid = profile.id(); UUID uuid = profile.id();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.name(); String name = profile.name();
UUID uuid = profile.id(); UUID uuid = profile.id();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.getName(); String name = profile.getName();
UUID uuid = profile.getId(); UUID uuid = profile.getId();
if (SaturnPlayer.get(name, uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.getName(); String name = profile.getName();
UUID uuid = profile.getId(); UUID uuid = profile.getId();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.getName(); String name = profile.getName();
UUID uuid = profile.getId(); UUID uuid = profile.getId();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.getName(); String name = profile.getName();
UUID uuid = profile.getId(); UUID uuid = profile.getId();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.getName(); String name = profile.getName();
UUID uuid = profile.getId(); UUID uuid = profile.getId();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }
@@ -1,43 +1,49 @@
package org.saturnclient.saturnclient.mixin; package org.saturnclient.saturnclient.mixin;
import net.minecraft.client.network.PlayerListEntry; import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.scoreboard.Team;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.Nullable;
import org.saturnclient.client.player.Roles; import org.saturnclient.client.player.Roles;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@Mixin(PlayerListEntry.class) @Mixin(PlayerListEntry.class)
public abstract class TabListMixin { public abstract class TabListMixin {
@Shadow
private GameProfile profile;
/** /**
* @author HexLeo * Adds the Saturn Client icon to the player's name if they are online with
* @reason Adds the Saturn Client icon to the player's name if they are online * Saturn Client, keeping any name, rank prefix or team formatting the server
* with Saturn Client * set.
*/ */
@Overwrite @Inject(method = "getDisplayName", at = @At("RETURN"), cancellable = true)
@Nullable private void saturn$addSaturnIcon(CallbackInfoReturnable<Text> cir) {
public Text getDisplayName() { PlayerListEntry entry = (PlayerListEntry) (Object) this;
GameProfile profile = ((PlayerListEntry) (Object) this).getProfile(); GameProfile profile = entry.getProfile();
String name = profile.name(); String name = profile.name();
UUID uuid = profile.id(); UUID uuid = profile.id();
if (SaturnPlayer.get(uuid) != null) { if (SaturnPlayer.get(name, uuid) == null) {
return Text.literal(Roles.getSaturnIndicator()) return;
.styled(style -> style.withColor(Roles.getIconColor(uuid)))
.append(Text.literal(name).styled(style -> style.withColor(Formatting.WHITE)));
} }
return Text.literal(name);
Text displayName = cir.getReturnValue();
// With no server-set name, vanilla shows the team-decorated profile name.
if (displayName == null) {
displayName = Team.decorateName(entry.getScoreboardTeam(), Text.literal(name));
}
cir.setReturnValue(Text.empty()
.append(Text.literal(Roles.getSaturnIndicator())
.styled(style -> style.withColor(Roles.getIconColor(uuid))))
.append(displayName));
} }
} }