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

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

  • Author

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

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

 

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

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.