From fa7566ebcdc06b3c1cbc753160fa46d5e61a752c Mon Sep 17 00:00:00 2001 From: 50ap5ud5 <50ap5ud5125@gmail.com> Date: Wed, 27 Dec 2023 23:31:30 +1100 Subject: [PATCH] ControlEntityRenderer tweaks -Made colour change less frequent for easier viewing experience -Fixed misdocumented variables --- .../renderer/entity/ControlEntityRenderer.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java index 029b390b7..4464eacea 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/entity/ControlEntityRenderer.java @@ -43,36 +43,34 @@ public void render(ControlEntity entity, float f, float g, PoseStack poseStack, } @Override - protected void renderNameTag(ControlEntity entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int textRenderingLayer) { + protected void renderNameTag(ControlEntity entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLightCoords) { MutableComponent textComponent = Component.literal(component.getString()); textComponent.withStyle(style -> style - .applyFormats(ChatFormatting.BOLD, (entity.level().random.nextInt(50) == 0) ? ChatFormatting.GOLD : ChatFormatting.YELLOW) + .applyFormats(ChatFormatting.BOLD, (entity.level().getGameTime() % 60 == 0) ? ChatFormatting.GOLD : ChatFormatting.YELLOW) ); double distanceSquared = this.entityRenderDispatcher.distanceToSqr(entity); if (!(distanceSquared > 4096.0)) { boolean isSolid = !entity.isDiscrete(); - float boundingBoxHeight = entity.getBbHeight() + 0.5F; + float boundingBoxHeight = entity.getNameTagOffsetY(); int verticalTextOffset = 35; poseStack.pushPose(); poseStack.translate(0.0, boundingBoxHeight, 0.0); poseStack.mulPose(this.entityRenderDispatcher.cameraOrientation()); - - float scale = 0.010F; poseStack.scale(-scale, -scale, scale); Matrix4f textMatrix = poseStack.last().pose(); - float textBackgroundOpacity = Minecraft.getInstance().options.getBackgroundOpacity(0.75F); + float textBackgroundOpacity = Minecraft.getInstance().options.getBackgroundOpacity(0.5F); int textColor = (int) (textBackgroundOpacity * 255.0F) << 24; Font font = this.getFont(); float textHorizontalPosition = (float) (-font.width(component) / 2); - font.drawInBatch(textComponent, textHorizontalPosition, (float) verticalTextOffset, 553648127, false, textMatrix, multiBufferSource, Font.DisplayMode.NORMAL, textColor, textRenderingLayer); + font.drawInBatch(textComponent, textHorizontalPosition, (float) verticalTextOffset, 553648127, false, textMatrix, multiBufferSource, Font.DisplayMode.SEE_THROUGH, textColor, packedLightCoords); if (isSolid) { - font.drawInBatch(textComponent, textHorizontalPosition, (float) verticalTextOffset, -1, false, textMatrix, multiBufferSource, Font.DisplayMode.SEE_THROUGH, 0, textRenderingLayer); + font.drawInBatch(textComponent, textHorizontalPosition, (float) verticalTextOffset, -1, false, textMatrix, multiBufferSource, Font.DisplayMode.NORMAL, 0, packedLightCoords); } poseStack.popPose();