From a9edd628cfb78077f40643e87bf7ba484d0e7d87 Mon Sep 17 00:00:00 2001 From: Uraneptus Date: Fri, 16 Aug 2024 19:51:44 +0200 Subject: [PATCH] it works again, yay --- .../java/vazkii/neat/HealthBarRenderer.java | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java index 13ed8e4..f98d6ac 100644 --- a/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java +++ b/Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java @@ -215,6 +215,7 @@ 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(); @@ -222,6 +223,18 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou 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); @@ -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;