Posted December 6, 20204 yr 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
December 7, 20204 yr 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.