some changes
This commit is contained in:
@@ -17,7 +17,6 @@ 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.auraclient.auraclient.auth.AuraApi;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -38,7 +37,7 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
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(state, y, text, matrices, vertexConsumers, light);
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
} else {
|
} else {
|
||||||
Vec3d vec3d = state.nameLabelPos;
|
Vec3d vec3d = state.nameLabelPos;
|
||||||
@@ -67,7 +66,7 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderTextAtOrigin(double y, Text text, MatrixStack matrices,
|
private void renderTextAtOrigin(S state, double y, Text text, MatrixStack matrices,
|
||||||
VertexConsumerProvider vertexConsumers, int light) {
|
VertexConsumerProvider vertexConsumers, int light) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
@@ -88,21 +87,30 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
|
|
||||||
float textWidth = textRenderer.getWidth(text);
|
float textWidth = textRenderer.getWidth(text);
|
||||||
float badgeSize = textWidth * 0.20f;
|
float badgeSize = textWidth * 0.20f;
|
||||||
float totalWidth = textWidth + badgeSize + 6;
|
float totalWidth = textWidth + badgeSize + 4;
|
||||||
|
|
||||||
// Adjust text position to make space for badge
|
// Adjust text position to make space for badge
|
||||||
float xStart = -totalWidth / 2 + badgeSize;
|
float xStart = -totalWidth / 2 + badgeSize;
|
||||||
|
|
||||||
// Draw a single background behind both text and badge
|
float backgroundX = -totalWidth / 2 - 3.9f;
|
||||||
drawBackground(matrices, vertexConsumers, -totalWidth / 2 - 4, -1.5f, totalWidth, 10, 0x55000000);
|
|
||||||
|
int j = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F)
|
||||||
|
* 255.0F) << 24;
|
||||||
|
|
||||||
|
drawBackground(state, matrices, vertexConsumers, backgroundX, -1.5f, totalWidth, 10, j);
|
||||||
|
|
||||||
// Render Badge
|
// Render Badge
|
||||||
renderBadgeIcon(matrices, vertexConsumers, xStart - badgeSize + 1, 3.4f, badgeSize);
|
renderBadgeIcon(matrices, vertexConsumers, xStart - badgeSize + 1, 3.4f, badgeSize, state.sneaking);
|
||||||
|
|
||||||
// Render Text with adjusted layer
|
if (state.sneaking) {
|
||||||
|
textRenderer.draw(text, xStart, 0, -2130706433, false, matrix4f, vertexConsumers,
|
||||||
|
TextLayerType.NORMAL, 0,
|
||||||
|
light);
|
||||||
|
} else {
|
||||||
textRenderer.draw(text, xStart, 0, -1, false, matrix4f, vertexConsumers,
|
textRenderer.draw(text, xStart, 0, -1, false, matrix4f, vertexConsumers,
|
||||||
net.minecraft.client.font.TextRenderer.TextLayerType.SEE_THROUGH, 0,
|
TextLayerType.SEE_THROUGH, 0,
|
||||||
LightmapTextureManager.applyEmission(light, 2));
|
LightmapTextureManager.applyEmission(light, 2));
|
||||||
|
}
|
||||||
|
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
@@ -110,47 +118,52 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
/**
|
/**
|
||||||
* Draws a single background behind both text and badge.
|
* Draws a single background behind both text and badge.
|
||||||
*/
|
*/
|
||||||
private void drawBackground(MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
private void drawBackground(S state, MatrixStack matrices, VertexConsumerProvider vertexConsumers,
|
||||||
float x, float y, float width, float height, int color) {
|
float x, float y, float width, float height, int color) {
|
||||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||||
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough());
|
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(
|
||||||
|
state.sneaking ? RenderLayer.getTextBackground()
|
||||||
|
: RenderLayer.getTextBackgroundSeeThrough());
|
||||||
|
|
||||||
int a = (color >> 24) & 255; // Alpha
|
int a = (color >> 24) & 255; // Alpha
|
||||||
int r = (color >> 16) & 255; // Red
|
int r = (color >> 16) & 255; // Red
|
||||||
int g = (color >> 8) & 255; // Green
|
int g = (color >> 8) & 255; // Green
|
||||||
int b = color & 255; // Blue
|
int b = color & 255; // Blue
|
||||||
|
|
||||||
vertexConsumer.vertex(matrix, x, y + height, 0).color(r, g, b, a).texture(0, 1).light(0xF000F0)
|
float z = state.sneaking ? -0.04f : 0.0f;
|
||||||
|
|
||||||
|
vertexConsumer.vertex(matrix, x, y + height, z).color(r, g, b, a).texture(0, 1).light(0xF000F0)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.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)
|
vertexConsumer.vertex(matrix, x + width, y + height, z).color(r, g, b, a).texture(1, 1).light(0xF000F0)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.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)
|
vertexConsumer.vertex(matrix, x + width, y, z).color(r, g, b, a).texture(1, 0).light(0xF000F0)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||||
vertexConsumer.vertex(matrix, x, y, 0).color(r, g, b, a).texture(0, 0).light(0xF000F0)
|
vertexConsumer.vertex(matrix, x, y, z).color(r, g, b, a).texture(0, 0).light(0xF000F0)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderBadgeIcon(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float x,
|
private void renderBadgeIcon(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float x,
|
||||||
float y, float size) {
|
float y, float size, boolean sneaking) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
// Position badge correctly
|
// Position badge correctly
|
||||||
matrices.translate(x, y, 0);
|
matrices.translate(x, y, 0);
|
||||||
matrices.scale(size, size, size); // Scale properly
|
matrices.scale(size, size, size);
|
||||||
|
|
||||||
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
Matrix4f matrix = matrices.peek().getPositionMatrix();
|
||||||
VertexConsumer vertexConsumer = vertexConsumers
|
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(
|
||||||
.getBuffer(RenderLayer.getEntityTranslucent(BADGE_TEXTURE));
|
RenderLayer.getEntityAlpha(BADGE_TEXTURE));
|
||||||
|
|
||||||
int fullBright = LightmapTextureManager.MAX_LIGHT_COORDINATE;
|
int light = LightmapTextureManager.MAX_LIGHT_COORDINATE;
|
||||||
|
|
||||||
vertexConsumer.vertex(matrix, -0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(0, 0).light(fullBright)
|
// If sneaking, render the badge in gray
|
||||||
|
vertexConsumer.vertex(matrix, -0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(0, 0).light(light)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.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)
|
vertexConsumer.vertex(matrix, 0.5f, -0.5f, 0).color(255, 255, 255, 255).texture(1, 0).light(light)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.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)
|
vertexConsumer.vertex(matrix, 0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(1, 1).light(light)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.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)
|
vertexConsumer.vertex(matrix, -0.5f, 0.5f, 0).color(255, 255, 255, 255).texture(0, 1).light(light)
|
||||||
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
.overlay(OverlayTexture.DEFAULT_UV).normal(0, 0, 1);
|
||||||
|
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
@@ -159,8 +172,6 @@ public abstract class NameTagMixin<S extends EntityRenderState> {
|
|||||||
private boolean isAura(S state) {
|
private boolean isAura(S state) {
|
||||||
if (state instanceof PlayerEntityRenderState) {
|
if (state instanceof PlayerEntityRenderState) {
|
||||||
String name = ((PlayerEntityRenderState) state).name;
|
String name = ((PlayerEntityRenderState) state).name;
|
||||||
AuraClient.LOGGER.info("Name: " + name);
|
|
||||||
AuraClient.LOGGER.info("Player Names: " + AuraApi.playerNames);
|
|
||||||
return AuraApi.playerNames.containsKey(name);
|
return AuraApi.playerNames.containsKey(name);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user