Skip to content

Commit

Permalink
show when the nametag is shown
Browse files Browse the repository at this point in the history
let it be rendered though walls if the nametag is being rendered
  • Loading branch information
olim88 committed Oct 30, 2024
1 parent f6caa10 commit b111cde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/main/java/de/hysky/skyblocker/skyblock/HealthBars.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private static void render(WorldRenderContext context) {
boolean hideFullHealth = SkyblockerConfigManager.get().uiAndVisuals.healthBars.hideFullHealth;
float scale = SkyblockerConfigManager.get().uiAndVisuals.healthBars.scale;
float tickDelta = context.tickCounter().getTickDelta(false);
float width = scale;
float height = scale * 0.1f;

for (Object2FloatMap.Entry<ArmorStandEntity> healthValue : healthValues.object2FloatEntrySet()) {
//if the health bar is full and the setting is enabled to hide it stop rendering it
Expand All @@ -213,11 +215,13 @@ private static void render(WorldRenderContext context) {
}

ArmorStandEntity armorStand = healthValue.getKey();
//only render health bar if name is visible
if (!armorStand.shouldRenderName()) {
return;
}
// Render the health bar texture with scaling based on health percentage
float width = scale;
float height = scale * 0.1f;
RenderHelper.renderTextureInWorld(context, armorStand.getCameraPosVec(tickDelta).add(0, 0.25 - height, 0), width, height, 1f, 1f, new Vec3d(width * -0.5f, 0, 0), HEALTH_BAR_BACKGROUND_TEXTURE, barColor, false);
RenderHelper.renderTextureInWorld(context, armorStand.getCameraPosVec(tickDelta).add(0, 0.25 - height, 0), width * health, height, health, 1f, new Vec3d(width * -0.5f, 0, 0.003f), HEALTH_BAR_TEXTURE, barColor, false);
RenderHelper.renderTextureInWorld(context, armorStand.getCameraPosVec(tickDelta).add(0, 0.25 - height, 0), width, height, 1f, 1f, new Vec3d(width * -0.5f, 0, 0), HEALTH_BAR_BACKGROUND_TEXTURE, barColor, true);
RenderHelper.renderTextureInWorld(context, armorStand.getCameraPosVec(tickDelta).add(0, 0.25 - height, 0), width * health, height, health, 1f, new Vec3d(width * -0.5f, 0, 0.003f), HEALTH_BAR_TEXTURE, barColor, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public static void renderTextureInWorld(WorldRenderContext context, Vec3d pos, f

RenderSystem.setShaderTexture(0, texture);
RenderSystem.setShaderColor(shaderColor.getRed() / 255f, shaderColor.getGreen() / 255f, shaderColor.getBlue() / 255f, shaderColor.getAlpha() / 255f);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
Expand Down

0 comments on commit b111cde

Please sign in to comment.