Skip to content

Commit

Permalink
it works again, yay
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Aug 16, 2024
1 parent 66d42cd commit a9edd62
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,26 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou
poseStack.pushPose();
poseStack.translate(0, living.getBbHeight() + NeatConfig.instance.heightAbove(), 0);
poseStack.mulPose(cameraOrientation);
poseStack.mulPose(Axis.YP.rotationDegrees(180));

// Plate background, bars, and text operate with globalScale, but icons don't
poseStack.pushPose();
poseStack.scale(-globalScale, -globalScale, globalScale);

VertexConsumer builder = buffers.getBuffer(NeatRenderType.BAR_TEXTURE_TYPE);

// Background
if (NeatConfig.instance.drawBackground()) {
float padding = NeatConfig.instance.backgroundPadding();
int bgHeight = NeatConfig.instance.backgroundHeight();


builder.addVertex(poseStack.last().pose(), -halfSize - padding, -bgHeight, 0.01F).setColor(0, 0, 0, 60).setUv(0.0F, 0.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize - padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 60).setUv(0.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 60).setUv(1.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, -bgHeight, 0.01F).setColor(0, 0, 0, 60).setUv(1.0F, 0.0F).setLight(light);
}

// Health Bar
{
int argb = getColor(living, NeatConfig.instance.colorByType(), boss);
Expand All @@ -232,34 +245,25 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou
// can temporarily exceed the max health.
float maxHealth = Math.max(living.getHealth(), living.getMaxHealth());
float healthHalfSize = halfSize * (living.getHealth() / maxHealth);
//TODO fix health bar reducing from left to right instead of right to left
builder.addVertex(poseStack.last().pose(), -halfSize, 0, 0.001F).setColor(r, g, b, 160).setUv(0.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize, barHeight, 0.001F).setColor(r, g, b, 160).setUv(0.0F, 1.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, barHeight, 0.001F).setColor(r, g, b, 160).setUv(1.0F, 1.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, 0, 0.001F).setColor(r, g, b, 160).setUv(1.0F, 0.75F).setLight(light);

//VertexConsumer builder = buffers.getBuffer(NeatRenderType.BAR_TEXTURE_TYPE);
//VertexConsumer builder = buffers.getBuffer(RenderType.LINES);
builder.addVertex(poseStack.last().pose(), -halfSize, 0, 0.001F).setColor(r, g, b, 127).setUv(0.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize, barHeight, 0.001F).setColor(r, g, b, 127).setUv(0.0F, 1.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, barHeight, 0.001F).setColor(r, g, b, 127).setUv(1.0F, 1.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, 0, 0.001F).setColor(r, g, b, 127).setUv(1.0F, 0.75F).setLight(light);

// Blank part of the bar
if (healthHalfSize < halfSize) {
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, 0, 0.001F).setColor(0, 0, 0, 64).setUv(0.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, barHeight, 0.001F).setColor(0, 0, 0, 64).setUv(0.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize, barHeight, 0.001F).setColor(0, 0, 0, 64).setUv(1.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize, 0, 0.001F).setColor(0, 0, 0, 64).setUv(1.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, 0, 0.001F).setColor(0, 0, 0, 127).setUv(0.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize + 2 * healthHalfSize, barHeight, 0.001F).setColor(0, 0, 0, 127).setUv(0.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize, barHeight, 0.001F).setColor(0, 0, 0, 127).setUv(1.0F, 0.75F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize, 0, 0.001F).setColor(0, 0, 0, 127).setUv(1.0F, 0.5F).setLight(light);
}
}

// Background
if (NeatConfig.instance.drawBackground()) {
float padding = NeatConfig.instance.backgroundPadding();
int bgHeight = NeatConfig.instance.backgroundHeight();

builder.addVertex(poseStack.last().pose(), -halfSize - padding, -bgHeight, 0.01F).setColor(0, 0, 0, 60).setUv(0.0F, 0.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize - padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 60).setUv(0.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 60).setUv(1.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, -bgHeight, 0.01F).setColor(0, 0, 0, 60).setUv(1.0F, 0.0F).setLight(light);
}

// Text
{//TODO fix text not rendering
{
final int white = 0xFFFFFF;
final int black = 0;

Expand Down

0 comments on commit a9edd62

Please sign in to comment.