Skip to content

Commit

Permalink
fix first few rendering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Aug 13, 2024
1 parent 754e0f7 commit 66d42cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
45 changes: 22 additions & 23 deletions Xplat/src/main/java/vazkii/neat/HealthBarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,7 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou
poseStack.pushPose();
poseStack.scale(-globalScale, -globalScale, globalScale);

// Background
if (NeatConfig.instance.drawBackground()) {
float padding = NeatConfig.instance.backgroundPadding();
int bgHeight = NeatConfig.instance.backgroundHeight();
VertexConsumer builder = buffers.getBuffer(NeatRenderType.BAR_TEXTURE_TYPE);
//VertexConsumer builder = buffers.getBuffer(RenderType.LINES);
builder.addVertex(poseStack.last().pose(), -halfSize - padding, -bgHeight, 0.01F).setColor(0, 0, 0, 64).setUv(0.0F, 0.0F).setLight(light);
builder.addVertex(poseStack.last().pose(), -halfSize - padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 64).setUv(0.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, barHeight + padding, 0.01F).setColor(0, 0, 0, 64).setUv(1.0F, 0.5F).setLight(light);
builder.addVertex(poseStack.last().pose(), halfSize + padding, -bgHeight, 0.01F).setColor(0, 0, 0, 64).setUv(1.0F, 0.0F).setLight(light);
}
VertexConsumer builder = buffers.getBuffer(NeatRenderType.BAR_TEXTURE_TYPE);

// Health Bar
{
Expand All @@ -242,25 +232,34 @@ 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);

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);
//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);

// Blank part of the bar
if (healthHalfSize < halfSize) {
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);
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);
}
}

// 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
3 changes: 1 addition & 2 deletions Xplat/src/main/java/vazkii/neat/NeatRenderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ private NeatRenderType(String string, Runnable r, Runnable r1) {
super(string, r, r1);
}

//TODO fix rendering
private static RenderType getHealthBarType() {
RenderType.CompositeState renderTypeState = RenderType.CompositeState.builder()
.setShaderState(POSITION_COLOR_TEX_LIGHTMAP_SHADER)
Expand All @@ -29,6 +28,6 @@ private static RenderType getHealthBarType() {
.setCullState(NO_CULL)
.setLightmapState(LIGHTMAP)
.createCompositeState(false);
return AccessorRenderType.neat_create("neat_health_bar", POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, true, true, renderTypeState);
return AccessorRenderType.neat_create("neat_health_bar", POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, 256, true, false, renderTypeState);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Done to increase the memory available to gradle.
# add-exports are needed for spotless to work on new Javas
org.gradle.jvmargs=-Xmx1G \
org.gradle.jvmargs=-Xmx2G \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
Expand Down

0 comments on commit 66d42cd

Please sign in to comment.