Jump to content

[BER] Rendered quads go dark depending on the player's position


Miyanber

Recommended Posts

I succeeded in rendering quads. However, they go dark when players are above them. Like these picture 

https://drive.google.com/file/d/1zdbiE-pmGk3VuLy5ZSPtPDo-4UpHcKsa/view?usp=sharing

https://drive.google.com/file/d/1AgJv2ncXjqRGh_oTURNCtVdMfDWws8s2/view?usp=sharing

Is there something wrong with my codes?

public class RenderTester implements BlockEntityRenderer<BlockEntityTester> {
    private static final ResourceLocation GRAVEL_TEXTURE = new ResourceLocation("textures/block/gravel.png");

    public RenderTester (BlockEntityRendererProvider.Context context) {}

    @Override
    public void render(@NotNull BlockEntityTester pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) {
        VertexConsumer builder = pBuffer.getBuffer(RenderType.entityCutoutNoCull(GRAVEL_TEXTURE));
        BufferUtil.drawQuad(builder, pPoseStack, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, pPackedLight, pPackedOverlay, 0xFFFFFFFF);
    }
}
public class BufferUtil {
    public static void drawVertex(VertexConsumer builder, PoseStack poseStack, float x, float y, float z, float u, float v, int packedLight, int pPackedOverlay, int color) {
        builder.vertex(poseStack.last().pose(), x, y, z)
                .color(color)
                .uv(u, v)
                .overlayCoords(pPackedOverlay)
                .uv2(packedLight)
                .normal(0, 1, 0)
                .endVertex();
    }
    public static void drawQuad(VertexConsumer builder, PoseStack poseStack, float x0, float y0, float z0, float x1, float y1, float z1, float u0, float v0, float u1, float v1, int packedLight, int pPackedOverlay, int color) {
        drawVertex(builder, poseStack, x0, y0, z0, u0, v0, packedLight, pPackedOverlay, color);
        drawVertex(builder, poseStack, x0, y1, z1, u0, v1, packedLight, pPackedOverlay, color);
        drawVertex(builder, poseStack, x1, y1, z1, u1, v1, packedLight, pPackedOverlay, color);
        drawVertex(builder, poseStack, x1, y0, z0, u1, v0, packedLight, pPackedOverlay, color);
    }
}

 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.