Posted March 21, 20205 yr So I have this problem with my custom Nametag. Some stuff is invisible behind it like chests and coloured glass as seen in the picture. I also think thats related to this bug since I use the RenderNameplateEvent Here is my code @SubscribeEvent public void onNameplateRender(RenderNameplateEvent event){ if (event.getEntity() instanceof TNTEntity && event.getEntity() != null){ TNTEntity entity = (TNTEntity)(event.getEntity()); EntityRendererManager manager = Minecraft.getInstance().getRenderManager(); IRenderTypeBuffer renderTypeBuffer = event.getRenderTypeBuffer(); renderTag(manager, entity, ticksToTime(entity.getFuse()), event.getMatrixStack(), renderTypeBuffer); } } @SuppressWarnings("rawtypes") private void renderTag(EntityRendererManager manager, Entity entity, String text, MatrixStack stack, IRenderTypeBuffer impl) { float height = entity.getHeight(); stack.push(); stack.translate(0.0D, height + 0.5F, 0.0D); stack.rotate(manager.getCameraOrientation()); stack.scale(-0.025F, -0.025F, 0.025F); Matrix4f matrix4f = stack.getLast().getMatrix(); FontRenderer fontRenderer = manager.getFontRenderer(); float offset = (float)(-fontRenderer.getStringWidth(text) / 2); fontRenderer.renderString(text, offset, 0F, 553648127, false, matrix4f, impl, true, 1056964608, 15728640); fontRenderer.renderString(text, offset, 0F, -1, false, matrix4f, impl, false, 1056964608, 15728640); stack.pop(); } private String ticksToTime(int ticks){ if(ticks > 20*3600){ int h = ticks/20/3600; return h+" h"; } else if(ticks > 20*60){ int m = ticks/20/60; return m+" m"; } else { int s = ticks / 20; int ms = (ticks % 20) / 2; return s+"."+ms+" s"; } } Do you maybe have an idea to get around this issue?
March 22, 20205 yr This issue has to do with the fact of see through text vs normal text rendering. Normal text rendering prioritizes all 'special' models behind the text to unload since the text is technically a solid object. See through text prioritizes the normal text to render behind any 'special' models making them appear to cut off the text. You have the correct implementation of using a see through rendered text with a normal rendered text, there is just one tiny error. To render the background of the text, you have to set the color equal to a value higher than 0. 1056964608 on the second renderString renders the background of the text as normal instead of making it transparent. So, you appear with the rendering bug. The way to fix it is just to change it to: fontRenderer.renderString(text, offset, 0F, 553648127, false, matrix4f, impl, true, 1056964608, 15728640); fontRenderer.renderString(text, offset, 0F, -1, false, matrix4f, impl, false, 0, 15728640); This should solve your issue.
March 22, 20205 yr Author Thank you so much! I've struggled with this issue for far too long I'm okay with to admit...
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.