Jump to content

Recommended Posts

Posted

Hey, I'm modding for 1.16.x at this moment, I wanna know how to draw text above an entity, I have an entity with a custom name but I want to write text above THAT custom name, how can I do it???

 

Thank you in advance,

Amit

Posted

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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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