some changes
This commit is contained in:
@@ -13,16 +13,16 @@ import java.net.URI;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AuraApi {
|
public class AuraApi {
|
||||||
private static final String URL = "http://localhost:3000";
|
private static final String URL = "http://localhost:3000";
|
||||||
|
|
||||||
private static String token = null;
|
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() {
|
public static boolean authenticate() {
|
||||||
try {
|
try {
|
||||||
@@ -54,7 +54,10 @@ public class AuraApi {
|
|||||||
|
|
||||||
JsonObject jsonResponse = JsonParser.parseString(response.toString()).getAsJsonObject();
|
JsonObject jsonResponse = JsonParser.parseString(response.toString()).getAsJsonObject();
|
||||||
boolean success = jsonResponse.get("success").getAsBoolean();
|
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) {
|
if (success) {
|
||||||
AuraClient.LOGGER.info("Successfully authenticated");
|
AuraClient.LOGGER.info("Successfully authenticated");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.auraclient.auraclient.auth;
|
package org.auraclient.auraclient.auth;
|
||||||
|
|
||||||
public class AuraPlayer {
|
public class AuraPlayer {
|
||||||
|
public String cloak;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.auraclient.auraclient.cloaks;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.auraclient.auraclient.AuraClient;
|
import org.auraclient.auraclient.AuraClient;
|
||||||
import org.auraclient.auraclient.auth.AuraApi;
|
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.AnimatedCloakData;
|
||||||
import org.auraclient.auraclient.cloaks.utils.IdentifierUtils;
|
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/";
|
private static final String CLOAKS_RESOURCE_PATH = "assets/auraclient/textures/cloaks/";
|
||||||
public static final List<String> availableCloaks = new ArrayList<>();
|
public static final List<String> availableCloaks = new ArrayList<>();
|
||||||
public static Identifier cloakCacheIdentifier = null;
|
public static Identifier cloakCacheIdentifier = null;
|
||||||
public static final Map<String, String> playerCloaks = new HashMap<>();
|
|
||||||
public static final Map<String, List<AnimatedCloakData>> animatedCloaks = new ConcurrentHashMap<>();
|
public static final Map<String, List<AnimatedCloakData>> animatedCloaks = new ConcurrentHashMap<>();
|
||||||
private static final Map<String, Long> lastFrameTime = new ConcurrentHashMap<>();
|
private static final Map<String, Long> lastFrameTime = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@@ -44,14 +44,22 @@ public class Cloaks {
|
|||||||
AuraApi.setCloak(cloakName);
|
AuraApi.setCloak(cloakName);
|
||||||
|
|
||||||
if (!cloakName.isEmpty()) {
|
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)) {
|
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
|
||||||
new Thread(() -> loadAnimatedCloak(uuid, cloakName + ".gif")).start();
|
new Thread(() -> loadAnimatedCloak(uuid, cloakName + ".gif")).start();
|
||||||
} else {
|
} else {
|
||||||
loadStaticCloak(cloakName + ".png");
|
loadStaticCloak(cloakName + ".png");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Cloaks.playerCloaks.remove(uuid);
|
AuraApi.players.remove(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,11 +129,11 @@ public class Cloaks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Identifier getCurrentCloakTexture(String uuid) {
|
public static Identifier getCurrentCloakTexture(String uuid) {
|
||||||
if (!playerCloaks.containsKey(uuid)) {
|
if (!AuraApi.players.containsKey(uuid)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cloakName = playerCloaks.get(uuid);
|
String cloakName = AuraApi.players.get(uuid).cloak;
|
||||||
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
|
if (Arrays.asList(ANIMATED_CLOAKS).contains(cloakName)) {
|
||||||
List<AnimatedCloakData> frames = animatedCloaks.get(uuid);
|
List<AnimatedCloakData> frames = animatedCloaks.get(uuid);
|
||||||
if (frames == null || frames.isEmpty()) {
|
if (frames == null || frames.isEmpty()) {
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
*/
|
*/
|
||||||
@Mixin(AbstractClientPlayerEntity.class)
|
@Mixin(AbstractClientPlayerEntity.class)
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public abstract class AbstractClientPlayerEntityMixin {
|
public abstract class CapeRenderer {
|
||||||
/**
|
/**
|
||||||
* Injects custom cloak textures into the player's skin textures.
|
* 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.util.math.Vec3d;
|
||||||
import net.minecraft.client.render.LightmapTextureManager;
|
import net.minecraft.client.render.LightmapTextureManager;
|
||||||
|
|
||||||
|
import org.auraclient.auraclient.AuraClient;
|
||||||
|
import org.auraclient.auraclient.auth.AuraApi;
|
||||||
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.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
@@ -32,15 +34,11 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
@Overwrite
|
@Overwrite
|
||||||
public void renderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
public void renderLabelIfPresent(S state, Text text, MatrixStack matrices,
|
||||||
VertexConsumerProvider vertexConsumers, int light) {
|
VertexConsumerProvider vertexConsumers, int light) {
|
||||||
if (state instanceof PlayerEntityRenderState) {
|
if (isAura(state)) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
matrices.translate(0.0f, 0.0f, 0.0f);
|
matrices.translate(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
double y = state.nameLabelPos.y;
|
double y = state.nameLabelPos.y;
|
||||||
|
|
||||||
renderTextAtOrigin(y, text, matrices, vertexConsumers, light);
|
renderTextAtOrigin(y, text, matrices, vertexConsumers, light);
|
||||||
|
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
} else {
|
} else {
|
||||||
Vec3d vec3d = state.nameLabelPos;
|
Vec3d vec3d = state.nameLabelPos;
|
||||||
@@ -54,11 +52,13 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||||
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
||||||
float f = (float) (-textRenderer.getWidth(text)) / 2.0F;
|
float f = (float) (-textRenderer.getWidth(text)) / 2.0F;
|
||||||
int j = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
|
int j = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F)
|
||||||
|
* 255.0F) << 24;
|
||||||
textRenderer.draw(text, f, (float) i, -2130706433, false, matrix4f, vertexConsumers,
|
textRenderer.draw(text, f, (float) i, -2130706433, false, matrix4f, vertexConsumers,
|
||||||
bl ? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL, j, light);
|
bl ? TextLayerType.SEE_THROUGH : TextLayerType.NORMAL, j, light);
|
||||||
if (bl) {
|
if (bl) {
|
||||||
textRenderer.draw(text, f, (float) i, -1, false, matrix4f, vertexConsumers, TextLayerType.NORMAL, 0,
|
textRenderer.draw(text, f, (float) i, -1, false, matrix4f, vertexConsumers,
|
||||||
|
TextLayerType.NORMAL, 0,
|
||||||
LightmapTextureManager.applyEmission(light, 2));
|
LightmapTextureManager.applyEmission(light, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,4 +155,14 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
|
|
||||||
matrices.pop();
|
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",
|
"minVersion": "0.8",
|
||||||
"package": "org.auraclient.auraclient.mixin",
|
"package": "org.auraclient.auraclient.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": ["AbstractClientPlayerEntityMixin", "NameTagMixin"],
|
"client": ["CapeRenderer", "NameTagMixin"],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user