Hello, sometime ago I asked help on this same thing and I figured something out, but the method I'm using is coming with a few problems. Foremost, it entirely breaks when using Optifine Shaders (I used the internal ones). And second of all, while it does render text the exact way I want it to, it doesn't have the transparent background like entity names would. Is there any better way to achieve what I'm trying to achieve? (This is all client side)
Here is my current function: (I call it in RenderWorldLastEvent)
protected void renderNameTag(MathUtils.Point pos, ITextComponent text, MatrixStack ms, IRenderTypeBuffer buffer, float partialTicks, float yOffset) {
Minecraft mc = Minecraft.getInstance();
int combinedLightIn = mc.getEntityRenderDispatcher().getPackedLightCoords(mc.player, partialTicks);
ms.pushPose();
ms.translate(pos.getX(), yOffset, pos.getY());
Quaternion q = mc.getEntityRenderDispatcher().cameraOrientation();
ms.mulPose(q);
ms.scale(-0.025F, -0.025F, 0.025F);
Matrix4f matrix4f = ms.last().pose();
float opacity = Minecraft.getInstance().options.getBackgroundOpacity(0.5F);
int alpha = (int)(opacity * 255.0F) << 24;
FontRenderer fontrenderer = Minecraft.getInstance().getEntityRenderDispatcher().getFont();
float width = (float)(-fontrenderer.width(text) / 2);
//fontrenderer.drawInBatch(text, f2, i, 553648127, false, matrix4f, buffer, false, j, p_225629_5_);
//fontrenderer.drawInBatch(text, width, 0f, 553648127, false, matrix4f, buffer, false, alpha, combinedLightIn);
fontrenderer.drawInBatch(text, width, 0f, -1, false, matrix4f, buffer, true, 0, combinedLightIn);
ms.popPose();
}
If you need any additional information, please ask.