Jump to content

Recommended Posts

Posted (edited)

OK so using RenderGameOverlayEvent I managed to check when the player have a certain item on the helmet slot but fore some reason the overlay itself don't work.

 

Here is the code:

public class MODIngameGui extends IngameGui
{

    protected static final ResourceLocation GASMASK_BLUR_TEX_PATH = new ResourceLocation("mod:textures/guis/gasmask.png");

    protected void renderGasmaskOverlay() {
        RenderSystem.disableDepthTest();
        RenderSystem.depthMask(false);
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
        RenderSystem.disableAlphaTest();
        this.mc.getTextureManager().bindTexture(GASMASK_BLUR_TEX_PATH);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(0.0D, (double)this.scaledHeight, -90.0D).tex(0.0F, 1.0F).endVertex();
        bufferbuilder.pos((double)this.scaledWidth, (double)this.scaledHeight, -90.0D).tex(1.0F, 1.0F).endVertex();
        bufferbuilder.pos((double)this.scaledWidth, 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(true);
        RenderSystem.enableDepthTest();
        RenderSystem.enableAlphaTest();
        RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    }

    public MODIngameGui(Minecraft mcIn, MatrixStack matrixStack)
    {
        super(mcIn);
        ItemStack itemstack = this.mc.player.inventory.armorItemInSlot(3);
        if (this.mc.gameSettings.getPointOfView().func_243192_a() && itemstack.getItem() == items_MOD.GAS_MASK.get()) {
            this.renderGasmaskOverlay();
            mod.LOGGER.info("test test test");
        }
    }
}

even tried to use, renderPumpkinOverlay but no success

 

the message appear in the console by the way

Edited by Grandlovania
Posted
@Mod.EventBusSubscriber
public class MODClientEvents
{
    @SubscribeEvent
    public static void RenderModOverlay(RenderGameOverlayEvent.Post event)
    {
        new MODIngameGui(Minecraft.getInstance(), event.getMatrixStack());
    }
}

 

Posted
3 hours ago, Grandlovania said:

Hi I would like to know how could I render an overlay (like pumpkin) once player have a certain armor piece on him.

If it is your own custom item, you could use the renderHelmetOverlay() method instead of an event.

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.