Jump to content

Recommended Posts

Posted

Hello everyone. I am having an issue with some GUI rendering I am trying to perform in my mod. I want to add a full screen multiple frame effect, and it all works, aside from that the transparent parts of the images are black and obscure vision.

I don't actually know much about GUI code, so a lot of this code is straight from the part of Minecraft that renders the pumpkin overlay, with some changes to add the multiple frame effect: 

public class TimeSkipEffectGUI extends AbstractGui {
    public static final Minecraft mc = Minecraft.getInstance();

    public void renderEffect() {
        PlayerEntity player = mc.player;

        if (mc.world == null) return;
        if (player == null) return;
        Stand.getLazyOptional(player).ifPresent(props -> {
            if (props.getTimeSkipEffectTicker() > 0) {

                RenderSystem.disableDepthTest();
                RenderSystem.depthMask(false);
                RenderSystem.defaultBlendFunc();
                RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

                Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation(DiamondIsUncraftable.MOD_ID, "textures/gui/timeskip/time_skip" + (16 - props.getTimeSkipEffectTicker()) + ".png"));

                Tessellator tessellator = Tessellator.getInstance();
                BufferBuilder bufferbuilder = tessellator.getBuffer();
                bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
                bufferbuilder.pos(0.0D, mc.getMainWindow().getScaledHeight(), -90.0D).tex(0.0F, 1.0F).endVertex();
                bufferbuilder.pos(mc.getMainWindow().getScaledWidth(), mc.getMainWindow().getScaledHeight(), -90.0D).tex(1.0F, 1.0F).endVertex();
                bufferbuilder.pos(mc.getMainWindow().getScaledWidth(), 0.0D, -90.0D).tex(1.0F, 0.0F).endVertex();
                bufferbuilder.pos(0.0D, 0.0D, -90.0D).tex(0.0F, 0.0F).endVertex();
                tessellator.draw();
                RenderSystem.depthMask(false);
                RenderSystem.enableDepthTest();
                RenderSystem.enableAlphaTest();
                RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            }
        });
    }
}

The images I am using are transparent in all other settings I have tested them in. I am wondering, do I need entirely new rendering code, or can this code be adapted with some setting changes? It confuses me how the pumpkin overlay texture has transparency in it and works yet these images don't.

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.

Announcements



×
×
  • Create New...

Important Information

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