Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to create a custom renderer for my entity and in order to do so I need to draw a sprite that has a lava texture and also a mask indicating which pixels to apply texture colors to. I've made quite a few attempts to implement this sort of thing, but all my scripts have either rendered nothing or just rendered a texture. Below is the code for my latest attempt. This code renders just a texture (instead of lava, I temporarily use a custom image). I would be grateful for any hints on how to fix it.

So this is my test script:

@Override
    public void render(EntityEruptionSource entity, float entityYaw, float partialTicks, PoseStack pose, MultiBufferSource buffer, int packedLight)
    {
        pose.pushPose();
        Vector3f vertexRotAxis = new Vector3f(0, 1, 0);
        
        GL11.glEnable(GL11.GL_STENCIL_TEST);
        GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
        GL11.glStencilMask(0xFF);
        GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
        GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE);
        VertexConsumer builder = buffer.getBuffer(RenderType.entityCutout(MainClass.RLof("textures/entities/eruption_source_mask.png")));
        Vector3f vertexPos = new Vector3f(-0.5f, 0.2f, 0.5f);
        for(int i = 0; i < 4; i++)
        {
            builder.vertex(pose.last().pose(), -vertexPos.x(), vertexPos.y(), -vertexPos.z())
                    .color(255, 255, 255, 255)
                    .uv(0, 0)
                    .overlayCoords(OverlayTexture.NO_OVERLAY)
                    .uv2(packedLight)
                    .normal(0, 1, 0)
                    .endVertex();
            vertexPos.transform(new Quaternion(vertexRotAxis, 90, true));
        }

        GL11.glStencilMask(0x00);
        GL11.glStencilFunc(GL11.GL_NOTEQUAL, 0, 0xFF);
        vertexPos = new Vector3f(-0.5f, 0.2f, 0.5f);
        VertexConsumer builder1 = buffer.getBuffer(RenderType.entityCutout(MainClass.RLof("textures/entities/eruption_source_c.png")));
        for(int i = 0; i < 4; i++)
        {
            builder1.vertex(pose.last().pose(), -vertexPos.x(), vertexPos.y(), -vertexPos.z())
                    .color(255, 255, 255, 255)
                    .uv(0, 0)
                    .overlayCoords(OverlayTexture.NO_OVERLAY)
                    .uv2(packedLight)
                    .normal(0, 1, 0)
                    .endVertex();
            vertexPos.transform(new Quaternion(vertexRotAxis, 90, true));
        }

        GL11.glDisable(GL11.GL_STENCIL_TEST);
        
        pose.popPose();

        super.render(entity, entityYaw, partialTicks, pose, buffer, packedLight);
    }

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.