diff --git a/gradle.properties b/gradle.properties index 5971ed7..d0a3409 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/client/java/dev/tggamesyt/szar/client/ClientCosmetics.java b/src/client/java/dev/tggamesyt/szar/client/ClientCosmetics.java new file mode 100644 index 0000000..8bf9951 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/ClientCosmetics.java @@ -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 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; + } +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/mixin/TGcapeMixin.java b/src/client/java/dev/tggamesyt/szar/client/mixin/TGcapeMixin.java new file mode 100644 index 0000000..170bc99 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/mixin/TGcapeMixin.java @@ -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 cir) { + AbstractClientPlayerEntity self = (AbstractClientPlayerEntity)(Object)this; + + var profile = ClientCosmetics.getProfile(self.getUuid()); + if (profile != null && profile.capeTexture != null) { + cir.setReturnValue(profile.capeTexture); + } + } +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/mixin/TGnameMixin.java b/src/client/java/dev/tggamesyt/szar/client/mixin/TGnameMixin.java new file mode 100644 index 0000000..98fc6e1 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/mixin/TGnameMixin.java @@ -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 cir) { + PlayerEntity self = (PlayerEntity)(Object)this; + + Text custom = ClientCosmetics.buildName( + self.getUuid(), + self.getGameProfile().getName() + ); + + if (custom != null) { + cir.setReturnValue(custom); + } + } +} \ No newline at end of file diff --git a/src/client/resources/szar.client.mixins.json b/src/client/resources/szar.client.mixins.json index e96ea3c..c67f807 100644 --- a/src/client/resources/szar.client.mixins.json +++ b/src/client/resources/szar.client.mixins.json @@ -7,7 +7,9 @@ "MouseMixin", "RadiationHeartMixin", "RadiatedItemRendererMixin", - "SplashOverlayMixin" + "SplashOverlayMixin", + "TGnameMixin", + "TGcapeMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/assets/szar/lang/en_us.json b/src/main/resources/assets/szar/lang/en_us.json index a1cf5ae..1070496 100644 --- a/src/main/resources/assets/szar/lang/en_us.json +++ b/src/main/resources/assets/szar/lang/en_us.json @@ -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", diff --git a/src/main/resources/assets/szar/models/item/atom.json b/src/main/resources/assets/szar/models/item/nuke.json similarity index 100% rename from src/main/resources/assets/szar/models/item/atom.json rename to src/main/resources/assets/szar/models/item/nuke.json diff --git a/src/main/resources/assets/szar/textures/etc/gabri_cape.png b/src/main/resources/assets/szar/textures/etc/gabri_cape.png new file mode 100644 index 0000000..2e9a131 Binary files /dev/null and b/src/main/resources/assets/szar/textures/etc/gabri_cape.png differ diff --git a/src/main/resources/assets/szar/textures/etc/tg_cape.png b/src/main/resources/assets/szar/textures/etc/tg_cape.png new file mode 100644 index 0000000..91190dd Binary files /dev/null and b/src/main/resources/assets/szar/textures/etc/tg_cape.png differ