Skip to content

Commit

Permalink
Fix a couple of nameplate rewrite related bugs and issues
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Sep 19, 2024
1 parent fab39b9 commit d3c9f1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private int drawWithColor(Font font, Component component, float x, float y, int
backgroundColor = figura$custom.background != null ? figura$custom.background : backgroundColor;
boolean deadmau = component.getString().equals("deadmau5");

// This renders the translucent part of the nametag you see when shifting, and the background
if (figura$isRenderingName()) {
int ret = 0;
// If the player's name is being rendered, render by lines otherwise just render whatever component is being passed. Applies for the rest of the loops below
Expand All @@ -130,7 +131,7 @@ private int drawWithColor(Font font, Component component, float x, float y, int
if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
ret = original.call(font, text1, x, y, color, shadow, matrix4f, multiBufferSource, displayMode, backgroundColor, light);
Expand All @@ -151,6 +152,7 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
boolean deadmau = component.getString().equals("deadmau5");

if (figura$enabled && figura$avatar != null && figura$hasCustomNameplate && figura$custom.outline) {
// This renders the opaque text with an outline if the player has that enabled.
int outlineColor = figura$custom.outlineColor != null ? figura$custom.outlineColor : 0x202020;
if (figura$isRenderingName()) {
for (int i = 0; i < figura$textList.size(); i++) {
Expand All @@ -159,7 +161,7 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
font.drawInBatch8xOutline(text1.getVisualOrderText(), x, y, color, outlineColor, matrix4f, multiBufferSource, light);
Expand All @@ -169,16 +171,16 @@ private int drawWithOutline(Font font, Component component, float x, float y, in
}
return original.call(font, Component.empty(), x, y, color, shadow, textMatrix.get(), multiBufferSource, displayMode, backgroundColor, light);
} else {
if (figura$enabled && figura$isRenderingName()) {
if (figura$enabled && figura$avatar != null && figura$hasCustomNameplate && figura$isRenderingName()) {
int ret = 0;

// This renders the opaque part of the nametag, that is text
for (int i = 0; i < figura$textList.size(); i++) {
Component text1 = figura$textList.get(i);

if (text1.getString().isEmpty())
continue;

int line = i - figura$textList.size() + (figura$hasScore() ? 0 : 1);
int line = i - figura$textList.size() + 1;
x = -font.width(text1) / 2f;
y = (deadmau ? -10f : 0f) + (font.lineHeight + 1) * line;
ret = original.call(font, text1, x, y, color, shadow, textMatrix.get(), multiBufferSource, displayMode, backgroundColor, light);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void setHasScore(AbstractClientPlayer player, Component text, PoseStack
return hasScore;
}

@ModifyArg(method = "renderNameTag(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"), index = 1)
@ModifyArg(method = "renderNameTag(Lnet/minecraft/client/player/AbstractClientPlayer;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;renderNameTag(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/network/chat/Component;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", ordinal = 1))
private Component modifyPlayerNameText(Component text, @Local(argsOnly = true) AbstractClientPlayer player) {
int config = Configs.ENTITY_NAMEPLATE.value;
if (config == 0 || AvatarManager.panic)
Expand Down

0 comments on commit d3c9f1e

Please sign in to comment.