cosmetics

This commit is contained in:
2026-02-22 16:34:58 +01:00
parent 8a35e0a455
commit 7b0d6cc850
9 changed files with 171 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.18.3
# Mod Properties
mod_version=26.2.18
mod_version=26.2.22
maven_group=dev.tggamesyt
archives_base_name=szar
# Dependencies

View File

@@ -0,0 +1,115 @@
package dev.tggamesyt.szar.client;
import dev.tggamesyt.szar.Szar;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class ClientCosmetics {
public enum NameType {
STATIC,
GRADIENT
}
public static class CosmeticProfile {
public final NameType nameType;
public final Formatting staticColor; // for STATIC names
public final Identifier capeTexture; // optional cape
public final int gradientStart; // RGB int, for GRADIENT
public final int gradientEnd; // RGB int, for GRADIENT
public CosmeticProfile(NameType nameType, Formatting staticColor, Identifier capeTexture,
int gradientStart, int gradientEnd) {
this.nameType = nameType;
this.staticColor = staticColor;
this.capeTexture = capeTexture;
this.gradientStart = gradientStart;
this.gradientEnd = gradientEnd;
}
}
// Registry
private static final Map<UUID, CosmeticProfile> PROFILES = new HashMap<>();
static {
// ===== TGdoesCode ===== animated gradient
PROFILES.put(
UUID.fromString("20bbb23e-2f22-46ba-b201-c6bd435b445b"),
new CosmeticProfile(
NameType.GRADIENT,
null,
new Identifier(Szar.MOD_ID, "textures/etc/tg_cape.png"),
0x8CD6FF, // light blue
0x00FFFF // cyan
)
);
// ===== Berci08ur_mom =====
PROFILES.put(
UUID.fromString("dda61748-15a4-45ff-9eea-29efc99c1711"),
new CosmeticProfile(
NameType.STATIC,
Formatting.GREEN,
new Identifier(Szar.MOD_ID, "textures/etc/gold_cape.png"),
0, 0
)
);
// ===== gabri =====
PROFILES.put(
UUID.fromString("52af5540-dd18-4ad9-9acb-50eb11531180"),
new CosmeticProfile(
NameType.STATIC,
Formatting.RED,
new Identifier(Szar.MOD_ID, "textures/etc/gbr_cape.png"),
0, 0
)
);
}
public static CosmeticProfile getProfile(UUID uuid) {
return PROFILES.get(uuid);
}
public static Text buildName(UUID uuid, String name) {
CosmeticProfile profile = PROFILES.get(uuid);
if (profile == null) return null;
if (profile.nameType == NameType.STATIC) {
return Text.literal(name).formatted(profile.staticColor, Formatting.BOLD);
}
// GRADIENT animation
long time = Util.getMeasuringTimeMs();
MutableText animated = Text.empty();
for (int i = 0; i < name.length(); i++) {
// Animate wave
float progress = (time * 0.08f) + (i * 1.2f);
float wave = (float) Math.sin(progress);
float t = (wave + 1f) / 2f; // 0..1
// Interpolate RGB
int r = (int) MathHelper.lerp(t, (profile.gradientStart >> 16) & 0xFF, (profile.gradientEnd >> 16) & 0xFF);
int g = (int) MathHelper.lerp(t, (profile.gradientStart >> 8) & 0xFF, (profile.gradientEnd >> 8) & 0xFF);
int b = (int) MathHelper.lerp(t, profile.gradientStart & 0xFF, profile.gradientEnd & 0xFF);
int color = (r << 16) | (g << 8) | b;
animated.append(
Text.literal(String.valueOf(name.charAt(i)))
.styled(style -> style.withColor(color).withBold(true))
);
}
return animated;
}
}

View File

@@ -0,0 +1,23 @@
package dev.tggamesyt.szar.client.mixin;
import dev.tggamesyt.szar.client.ClientCosmetics;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AbstractClientPlayerEntity.class)
public abstract class TGcapeMixin {
@Inject(method = "getCapeTexture", at = @At("HEAD"), cancellable = true)
private void injectCapeTexture(CallbackInfoReturnable<Identifier> cir) {
AbstractClientPlayerEntity self = (AbstractClientPlayerEntity)(Object)this;
var profile = ClientCosmetics.getProfile(self.getUuid());
if (profile != null && profile.capeTexture != null) {
cir.setReturnValue(profile.capeTexture);
}
}
}

View File

@@ -0,0 +1,27 @@
package dev.tggamesyt.szar.client.mixin;
import dev.tggamesyt.szar.client.ClientCosmetics;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public abstract class TGnameMixin {
@Inject(method = "getDisplayName", at = @At("HEAD"), cancellable = true)
private void overrideName(CallbackInfoReturnable<Text> cir) {
PlayerEntity self = (PlayerEntity)(Object)this;
Text custom = ClientCosmetics.buildName(
self.getUuid(),
self.getGameProfile().getName()
);
if (custom != null) {
cir.setReturnValue(custom);
}
}
}

View File

@@ -7,7 +7,9 @@
"MouseMixin",
"RadiationHeartMixin",
"RadiatedItemRendererMixin",
"SplashOverlayMixin"
"SplashOverlayMixin",
"TGnameMixin",
"TGcapeMixin"
],
"injectors": {
"defaultRequire": 1

View File

@@ -56,12 +56,12 @@
"item.szar.epstein_spawn_egg": "Epstein Spawn Egg",
"item.szar.detonator": "Detonator",
"entity.szar.atom": "Atom",
"entity.szar.nuke": "Nuke",
"block.szar.uranium_ore": "Uranium Ore",
"item.szar.uranium": "Uranium",
"item.szar.uranium_rod": "Uranium Rod",
"item.szar.nuke_core": "Nuke Core",
"item.szar.atom": "Nuke",
"item.szar.nuke": "Nuke",
"effect.szar.radiation": "Radiation",
"item.szar.baiter": "Music Disc",
"item.szar.baiter.desc": "HaVexy - Hyperabaiter Disstrack",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB