Name tag service
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
package org.saturnclient.saturnclient;
|
package org.saturnclient.saturnclient;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
import org.saturnclient.ui2.resources.Textures;
|
import org.saturnclient.ui2.resources.Textures;
|
||||||
@@ -16,6 +20,17 @@ public class SaturnClientConfig {
|
|||||||
public static Property<Boolean> bendyCloaks = Property.bool(true);
|
public static Property<Boolean> bendyCloaks = Property.bool(true);
|
||||||
public static Property<Integer> openEmoteWheel = Property.keybinding(GLFW.GLFW_KEY_B);
|
public static Property<Integer> openEmoteWheel = Property.keybinding(GLFW.GLFW_KEY_B);
|
||||||
|
|
||||||
|
static enum Role {
|
||||||
|
OWNER,
|
||||||
|
ADMIN,
|
||||||
|
PARTNER,
|
||||||
|
CONTRIBUTOR
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<UUID, Role> ROLES = Map.of(
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
public static Identifier getLogo() {
|
public static Identifier getLogo() {
|
||||||
return realisticLogo.value ? Textures.REALISTIC_LOGO : Textures.LOGO;
|
return realisticLogo.value ? Textures.REALISTIC_LOGO : Textures.LOGO;
|
||||||
}
|
}
|
||||||
@@ -33,12 +48,25 @@ public class SaturnClientConfig {
|
|||||||
* - Contributor: Aqua
|
* - Contributor: Aqua
|
||||||
* - Other/player: White
|
* - Other/player: White
|
||||||
*/
|
*/
|
||||||
public static Formatting getIconColor(String uuid) {
|
public static Formatting getIconColor(UUID uuid) {
|
||||||
if (uuid.equals("d362a04228bd49e1a807ae74dbe8aba9")) {
|
Role role = ROLES.get(uuid);
|
||||||
return Formatting.DARK_RED; // Owner
|
|
||||||
}
|
|
||||||
|
|
||||||
return Formatting.WHITE;
|
switch (role) {
|
||||||
|
case OWNER:
|
||||||
|
return Formatting.DARK_RED;
|
||||||
|
|
||||||
|
case ADMIN:
|
||||||
|
return Formatting.RED;
|
||||||
|
|
||||||
|
case PARTNER:
|
||||||
|
return Formatting.GOLD;
|
||||||
|
|
||||||
|
case CONTRIBUTOR:
|
||||||
|
return Formatting.AQUA;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Formatting.WHITE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import net.minecraft.util.Formatting;
|
|||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.auth.Auth;
|
import org.saturnclient.saturnclient.client.player.SaturnPlayer;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -37,11 +40,11 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
private void onRenderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
private void onRenderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
||||||
VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
|
||||||
|
|
||||||
String uuid = isSaturn(state);
|
UUID uuid = isSaturn(state);
|
||||||
|
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
MutableText iconText = Text.literal(SaturnClientConfig.getSaturnIndicator())
|
MutableText iconText = Text.literal(SaturnClientConfig.getSaturnIndicator())
|
||||||
.styled(style -> style.withColor(SaturnClientConfig.getIconColor(uuid)));
|
.styled(style -> style.withColor(SaturnClientConfig.getIconColor(uuid)));
|
||||||
|
|
||||||
Text nameText = text.copy().styled(style -> style.withColor(Formatting.WHITE));
|
Text nameText = text.copy().styled(style -> style.withColor(Formatting.WHITE));
|
||||||
|
|
||||||
@@ -52,13 +55,11 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String isSaturn(S state) {
|
private UUID isSaturn(S state) {
|
||||||
if (state instanceof PlayerEntityRenderState) {
|
if (state instanceof PlayerEntityRenderState) {
|
||||||
String name = ((PlayerEntityRenderState) state).name;
|
String name = ((PlayerEntityRenderState) state).name;
|
||||||
String uuid = Auth.playerNames.get(name);
|
SaturnPlayer player = SaturnPlayer.get(name);
|
||||||
if (Auth.players.containsKey(uuid)) {
|
return player.uuid;
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user