Posted March 9, 20232 yr Hello all, I have a mod that renders a cube the size of a chunk to simulate a "rain"-like effect. This worked well in 1.18.2 using borrowed code from the vanilla rain rendering. That stopped working, so I'm trying to actually understand the rendering process, rather than just copy-paste-praying. I copied the code from `LevelRenderer.renderLineBox` which worked perfectly in a `RenderLevelStageEvent` handler, but only rendered lines. I switched the RenderType to translucent and now I'm getting an IllegalStateException with the message "Not filled all elements of the vertex". I understand this means I am missing a value from the vertex builder chain, but I'm not sure what I'm missing here. The DefaultVertexFormat for "block" (used by RenderType.transparent) specifies that it needs 6 values: position, color, uv0, uv2, normal, and padding. public static final VertexFormat BLOCK = new VertexFormat(ImmutableMap.<String, VertexFormatElement>builder().put("Position", ELEMENT_POSITION).put("Color", ELEMENT_COLOR).put("UV0", ELEMENT_UV0).put("UV2", ELEMENT_UV2).put("Normal", ELEMENT_NORMAL).put("Padding", ELEMENT_PADDING).build()); In my code, I am providing 6 values: vertex, color, uv, uv2, normal, and I believe padding is automatically implied. VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2); vertex = vertex.color(r, g2, b2, a); vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F); vertex = vertex.uv(0, 0); vertex = vertex.uv2(0, 0); vertex.endVertex(); But my "elementIndex" ends up being "4", causing the exception. Here is the link to the entire file: - https://github.com/bradsk88/EurekaCraft/blob/c4a3eb76468fef861fbcfbe7423f59683f9537ec/src/main/java/ca/bradj/eurekacraft/client/ChunkStormCubeForgeRendering.java#L99 Can anyone spot what I'm doing wrong here? Edited March 9, 20232 yr by bradsk88
April 17, 20232 yr Author Turns out the order of calls in the chain is important. I had to update my calls to vertex to be in the same order as `VertexFormat BLOCK` VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2); vertex = vertex.color(r, g2, b2, a); vertex = vertex.uv(0, 0); vertex = vertex.uv2(0, 0); vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F); vertex.endVertex();
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.