Jump to content

Rendering Text above Entity


CrAzyScream

Recommended Posts

Take a look at how `EntityRenderer.renderName(Entity,String,MatrixStack,IRenderTypeBuffer,int)void` does it, and copy something like it.
You could also use something like this that I wrote for 1.15, it should be pretty similar in 1.16:

public static void renderName(Quaternion cameraOrientation, FontRenderer fontrenderer, String displayNameIn, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, double x, double y, double z) {
		matrixStackIn.push();
		matrixStackIn.translate(x, y, z);
		matrixStackIn.rotate(cameraOrientation);
		matrixStackIn.scale(-0.025F, -0.025F, 0.025F);
		Matrix4f matrix4f = matrixStackIn.getLast().getMatrix();
		float f1 = Minecraft.getInstance().gameSettings.getTextBackgroundOpacity(0.25F);
		int j = (int) (f1 * 255.0F) << 24;
		float f2 = (float) (-fontrenderer.getStringWidth(displayNameIn) / 2);
		fontrenderer.renderString(displayNameIn, f2, 0, 553648127, false, matrix4f, bufferIn, false, j, packedLightIn);
		fontrenderer.renderString(displayNameIn, f2, 0, -1, false, matrix4f, bufferIn, false, 0, packedLightIn);
		matrixStackIn.pop();
	}

 

Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.