some changes
This commit is contained in:
@@ -13,16 +13,16 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AuraApi {
|
||||
private static final String URL = "http://localhost:3000";
|
||||
|
||||
private static String token = null;
|
||||
private static String uuid = null;
|
||||
|
||||
public static List<AuraPlayer> players = new ArrayList<>();
|
||||
public static Map<String, AuraPlayer> players = new HashMap<>();
|
||||
public static Map<String, String> playerNames = new HashMap<>();
|
||||
|
||||
public static boolean authenticate() {
|
||||
try {
|
||||
@@ -54,7 +54,10 @@ public class AuraApi {
|
||||
|
||||
JsonObject jsonResponse = JsonParser.parseString(response.toString()).getAsJsonObject();
|
||||
boolean success = jsonResponse.get("success").getAsBoolean();
|
||||
uuid = jsonResponse.get("uuid").getAsString().replace("-", "");
|
||||
String uuid = jsonResponse.get("uuid").getAsString().replace("-", "");
|
||||
String name = jsonResponse.get("name").getAsString();
|
||||
|
||||
playerNames.put(name, uuid);
|
||||
|
||||
if (success) {
|
||||
AuraClient.LOGGER.info("Successfully authenticated");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package org.auraclient.auraclient.auth;
|
||||
|
||||
public class AuraPlayer {
|
||||
|
||||
public String cloak;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.auraclient.auraclient.cloaks;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.auraclient.auraclient.AuraClient;
|
||||
import org.auraclient.auraclient.auth.AuraApi;
|
||||
import org.auraclient.auraclient.auth.AuraPlayer;
|
||||
import org.auraclient.auraclient.cloaks.utils.AnimatedCloakData;
|
||||
import org.auraclient.auraclient.cloaks.utils.IdentifierUtils;
|
||||
|
||||
@@ -23,7 +24,6 @@ public class Cloaks {
|
||||
private static final String CLOAKS_RESOURCE_PATH = "assets/auraclient/textures/cloaks/";
|
||||
public static final List<String> availableCloaks = new ArrayList<>();
|
||||
public static Identifier cloakCacheIdentifier = null;
|
||||
public static final Map<String, String> playerCloaks = new HashMap<>();
|
||||
public static final Map<String, List<AnimatedCloakData>> animatedCloaks = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Long> lastFrameTime = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -44,14 +44,22 @@ public class Cloaks {
|
||||
AuraApi.setCloak(cloakName);
|
||||
|
||||
if (!cloakName.isEmpty()) {
|
||||
Cloaks.playerCloaks.put(uuid, cloakName);
|
||||
AuraPlayer player = AuraApi.players.get(uuid);
|
||||
if (player == null) {
|
||||
AuraPlayer newPlayer = new AuraPlayer();
|
||||
newPlayer.cloak = cloakName;
|
||||
AuraApi.players.put(uuid, newPlayer);
|
||||
} else {
|
||||
player.cloak = cloakName;
|
||||
}
|
||||
|
||||
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
|
||||
new Thread(() -> loadAnimatedCloak(uuid, cloakName + ".gif")).start();
|
||||
} else {
|
||||
loadStaticCloak(cloakName + ".png");
|
||||
}
|
||||
} else {
|
||||
Cloaks.playerCloaks.remove(uuid);
|
||||
AuraApi.players.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +129,11 @@ public class Cloaks {
|
||||
}
|
||||
|
||||
public static Identifier getCurrentCloakTexture(String uuid) {
|
||||
if (!playerCloaks.containsKey(uuid)) {
|
||||
if (!AuraApi.players.containsKey(uuid)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String cloakName = playerCloaks.get(uuid);
|
||||
String cloakName = AuraApi.players.get(uuid).cloak;
|
||||
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
|
||||
List<AnimatedCloakData> frames = animatedCloaks.get(uuid);
|
||||
if (frames == null || frames.isEmpty()) {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
*/
|
||||
@Mixin(AbstractClientPlayerEntity.class)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public abstract class AbstractClientPlayerEntityMixin {
|
||||
public abstract class CapeRenderer {
|
||||
/**
|
||||
* Injects custom cloak textures into the player's skin textures.
|
||||
*/
|
||||
@@ -17,6 +17,8 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
|
||||
import org.auraclient.auraclient.AuraClient;
|
||||
import org.auraclient.auraclient.auth.AuraApi;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -24,135 +26,143 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public abstract class NameTagMixin<S extends EntityRenderState> {
|
||||
private static final Identifier BADGE_TEXTURE = Identifier.of("auraclient", "textures/player-badge.png");
|
||||
private static final Identifier BADGE_TEXTURE = Identifier.of("auraclient", "textures/player-badge.png");
|
||||
|
||||
@Shadow
|
||||
public EntityRenderDispatcher dispatcher;
|
||||
@Shadow
|
||||
public EntityRenderDispatcher dispatcher;
|
||||
|
||||
@Overwrite
|
||||
public void renderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light) {
|
||||
if (state instanceof PlayerEntityRenderState) {
|
||||
matrices.push();
|
||||
@Overwrite
|
||||
public void renderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light) {
|
||||
if (isAura(state)) {
|
||||
matrices.push();
|
||||
matrices.translate(0.0f, 0.0f, 0.0f);
|
||||
double y = state.nameLabelPos.y;
|
||||
renderTextAtOrigin(y, text, matrices, vertexConsumers, light);
|
||||
matrices.pop();
|
||||
} else {
|
||||
Vec3d vec3d = state.nameLabelPos;
|
||||
if (vec3d != null) {
|
||||
boolean bl = !state.sneaking;
|
||||
int i = "deadmau5".equals(text.getString()) ? -10 : 0;
|
||||
matrices.push();
|
||||
matrices.translate(vec3d.x, vec3d.y + 0.5, vec3d.z);
|
||||
matrices.multiply(this.dispatcher.getRotation());
|
||||
matrices.scale(0.025F, -0.025F, 0.025F);
|
||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
float f = (float) (-textRenderer.getWidth(text)) / 2.0F;
|
||||
int j = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F)
|
||||
* 255.0F) << 24;
|
||||
textRenderer.draw(text, f, (float) i, -2130706433, false, matrix4f, vertexConsumers,
|
||||
bl ? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL, j, light);
|
||||
if (bl) {
|
||||
textRenderer.draw(text, f, (float) i, -1, false, matrix4f, vertexConsumers,
|
||||
TextLayerType.NORMAL, 0,
|
||||
LightmapTextureManager.applyEmission(light, 2));
|
||||
}
|
||||
|
||||
matrices.translate(0.0f, 0.0f, 0.0f);
|
||||
|
||||
double y = state.nameLabelPos.y;
|
||||
|
||||
renderTextAtOrigin(y, text, matrices, vertexConsumers, light);
|
||||
|
||||
matrices.pop();
|
||||
} else {
|
||||
Vec3d vec3d = state.nameLabelPos;
|
||||
if (vec3d != null) {
|
||||
boolean bl = !state.sneaking;
|
||||
int i = "deadmau5".equals(text.getString()) ? -10 : 0;
|
||||
matrices.push();
|
||||
matrices.translate(vec3d.x, vec3d.y + 0.5, vec3d.z);
|
||||
matrices.multiply(this.dispatcher.getRotation());
|
||||
matrices.scale(0.025F, -0.025F, 0.025F);
|
||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
float f = (float) (-textRenderer.getWidth(text)) / 2.0F;
|
||||
int j = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
|
||||
textRenderer.draw(text, f, (float) i, -2130706433, false, matrix4f, vertexConsumers,
|
||||
bl ? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL, j, light);
|
||||
if (bl) {
|
||||
textRenderer.draw(text, f, (float) i, -1, false, matrix4f, vertexConsumers, TextLayerType.NORMAL, 0,
|
||||
LightmapTextureManager.applyEmission(light, 2));
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderTextAtOrigin(double y, Text text, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light) {
|
||||
matrices.push();
|
||||
|
||||
// Move up slightly
|
||||
matrices.translate(0.0f, y + 0.5f, 0.0f);
|
||||
|
||||
// Apply rotation to face the camera
|
||||
matrices.multiply(dispatcher.getRotation());
|
||||
|
||||
// Scale text and badge to a readable size
|
||||
matrices.scale(0.025F, -0.025F, 0.025F);
|
||||
|
||||
// Offset the text to avoid Z-fighting
|
||||
matrices.translate(0.0F, 0.0F, -0.01F);
|
||||
|
||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||
net.minecraft.client.font.TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
|
||||
float textWidth = textRenderer.getWidth(text);
|
||||
float badgeSize = textWidth * 0.20f;
|
||||
float totalWidth = textWidth + badgeSize + 6;
|
||||
|
||||
// Adjust text position to make space for badge
|
||||
float xStart = -totalWidth / 2 + badgeSize;
|
||||
|
||||
// Draw a single background behind both text and badge
|
||||
drawBackground(matrices, vertexConsumers, -totalWidth / 2 - 4, -1.5f, totalWidth, 10, 0x55000000);
|
||||
|
||||
// Render Badge
|
||||
renderBadgeIcon(matrices, vertexConsumers, xStart - badgeSize + 1, 3.4f, badgeSize);
|
||||
|
||||
// Render Text with adjusted layer
|
||||
textRenderer.draw(text, xStart, 0, -1, false, matrix4f, vertexConsumers,
|
||||
net.minecraft.client.font.TextRenderer.TextLayerType.SEE_THROUGH, 0,
|
||||
LightmapTextureManager.applyEmission(light, 2));
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderTextAtOrigin(double y, Text text, MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers, int light) {
|
||||
matrices.push();
|
||||
/**
|
||||
* Draws a single background behind both text and badge.
|
||||
*/
|
||||
private void drawBackground(MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||
float x, float y, float width, float height, int color) {
|
||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough());
|
||||
|
||||
// Move up slightly
|
||||
matrices.translate(0.0f, y + 0.5f, 0.0f);
|
||||
int a = (color >> 24) & 255; // Alpha
|
||||
int r = (color >> 16) & 255; // Red
|
||||
int g = (color >> 8) & 255; // Green
|
||||
int b = color & 255; // Blue
|
||||
|
||||
// Apply rotation to face the camera
|
||||
matrices.multiply(dispatcher.getRotation());
|
||||
vertexConsumer.vertex(matrix, x, y + height, 0).color(r, g, b, a).texture(0, 1).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x + width, y + height, 0).color(r, g, b, a).texture(1, 1).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x + width, y, 0).color(r, g, b, a).texture(1, 0).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x, y, 0).color(r, g, b, a).texture(0, 0).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
}
|
||||
|
||||
// Scale text and badge to a readable size
|
||||
matrices.scale(0.025F, -0.025F, 0.025F);
|
||||
private void renderBadgeIcon(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float x,
|
||||
float y, float size) {
|
||||
matrices.push();
|
||||
|
||||
// Offset the text to avoid Z-fighting
|
||||
matrices.translate(0.0F, 0.0F, -0.01F);
|
||||
// Position badge correctly
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.scale(size, size, size); // Scale properly
|
||||
|
||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||
net.minecraft.client.font.TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||
VertexConsumer vertexConsumer = vertexConsumers
|
||||
.getBuffer(RenderLayer.getEntityTranslucent(BADGE_TEXTURE));
|
||||
|
||||
float textWidth = textRenderer.getWidth(text);
|
||||
float badgeSize = textWidth * 0.20f;
|
||||
float totalWidth = textWidth + badgeSize + 6;
|
||||
int fullBright = LightmapTextureManager.MAX_LIGHT_COORDINATE;
|
||||
|
||||
// Adjust text position to make space for badge
|
||||
float xStart = -totalWidth / 2 + badgeSize;
|
||||
vertexConsumer.vertex(matrix, -0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(0, 0).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, 0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(1, 0).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, 0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(1, 1).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, -0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(0, 1).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
|
||||
// Draw a single background behind both text and badge
|
||||
drawBackground(matrices, vertexConsumers, -totalWidth / 2 - 4, -1.5f, totalWidth, 10, 0x55000000);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
// Render Badge
|
||||
renderBadgeIcon(matrices, vertexConsumers, xStart - badgeSize + 1, 3.4f, badgeSize);
|
||||
|
||||
// Render Text with adjusted layer
|
||||
textRenderer.draw(text, xStart, 0, -1, false, matrix4f, vertexConsumers,
|
||||
net.minecraft.client.font.TextRenderer.TextLayerType.SEE_THROUGH, 0,
|
||||
LightmapTextureManager.applyEmission(light, 2));
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a single background behind both text and badge.
|
||||
*/
|
||||
private void drawBackground(MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||
float x, float y, float width, float height, int color) {
|
||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough());
|
||||
|
||||
int a = (color >> 24) & 255; // Alpha
|
||||
int r = (color >> 16) & 255; // Red
|
||||
int g = (color >> 8) & 255; // Green
|
||||
int b = color & 255; // Blue
|
||||
|
||||
vertexConsumer.vertex(matrix, x, y + height, 0).color(r, g, b, a).texture(0, 1).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x + width, y + height, 0).color(r, g, b, a).texture(1, 1).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x + width, y, 0).color(r, g, b, a).texture(1, 0).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, x, y, 0).color(r, g, b, a).texture(0, 0).light(0xF000F0)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
}
|
||||
|
||||
private void renderBadgeIcon(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float x,
|
||||
float y, float size) {
|
||||
matrices.push();
|
||||
|
||||
// Position badge correctly
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.scale(size, size, size); // Scale properly
|
||||
|
||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||
VertexConsumer vertexConsumer = vertexConsumers
|
||||
.getBuffer(RenderLayer.getEntityTranslucent(BADGE_TEXTURE));
|
||||
|
||||
int fullBright = LightmapTextureManager.MAX_LIGHT_COORDINATE;
|
||||
|
||||
vertexConsumer.vertex(matrix, -0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(0, 0).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, 0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(1, 0).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, 0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(1, 1).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
vertexConsumer.vertex(matrix, -0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(0, 1).light(fullBright)
|
||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
private boolean isAura(S state) {
|
||||
if (state instanceof PlayerEntityRenderState) {
|
||||
String name = ((PlayerEntityRenderState) state).name;
|
||||
AuraClient.LOGGER.info("Name: " + name);
|
||||
AuraClient.LOGGER.info("Player Names: " + AuraApi.playerNames);
|
||||
return AuraApi.playerNames.containsKey(name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"minVersion": "0.8",
|
||||
"package": "org.auraclient.auraclient.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": ["AbstractClientPlayerEntityMixin", "NameTagMixin"],
|
||||
"client": ["CapeRenderer", "NameTagMixin"],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user