Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Making a pumpkin like overlay (1.16.4)
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Grandlovania

Making a pumpkin like overlay (1.16.4)

By Grandlovania, November 28, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Grandlovania    0

Grandlovania

Grandlovania    0

  • Tree Puncher
  • Grandlovania
  • Members
  • 0
  • 3 posts
Posted November 28, 2020

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

  • Quote

Share this post


Link to post
Share on other sites

Beethoven92    69

Beethoven92

Beethoven92    69

  • Dragon Slayer
  • Beethoven92
  • Members
  • 69
  • 558 posts
Posted November 28, 2020

Subscribe to the RenderGameOverlayEvent and check if the player is wearing the armor piece you want. The IngameGui class is a good source of informations, there you can find how vanilla renders the pumpkin overlay

  • Quote

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

A little fun project: https://www.curseforge.com/minecraft/mc-mods/two-players-one-horse

Share this post


Link to post
Share on other sites

Grandlovania    0

Grandlovania

Grandlovania    0

  • Tree Puncher
  • Grandlovania
  • Members
  • 0
  • 3 posts
Posted November 28, 2020 (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 November 28, 2020 by Grandlovania
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7610

diesieben07

diesieben07    7610

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7610
  • 55159 posts
Posted November 28, 2020
  • Why on earth are you rendering things in the constructor?
  • Why are you extending IngameGui?
  • Show your event handler.
  • Quote

Share this post


Link to post
Share on other sites

Grandlovania    0

Grandlovania

Grandlovania    0

  • Tree Puncher
  • Grandlovania
  • Members
  • 0
  • 3 posts
Posted November 28, 2020
@Mod.EventBusSubscriber
public class MODClientEvents
{
    @SubscribeEvent
    public static void RenderModOverlay(RenderGameOverlayEvent.Post event)
    {
        new MODIngameGui(Minecraft.getInstance(), event.getMatrixStack());
    }
}

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7610

diesieben07

diesieben07    7610

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7610
  • 55159 posts
Posted November 28, 2020
  • You must check RenderGameOverlayEvent#getType, otherwise you render many times every frame.
  • When binding a texture in RenderGameOverlayEvent, you must bind AbstractGui.GUI_ICONS_LOCATION afterwards, as that is what Minecraft expects.
  • My other two points still stand.
  • Quote

Share this post


Link to post
Share on other sites

vemerion    56

vemerion

vemerion    56

  • Creeper Killer
  • vemerion
  • Members
  • 56
  • 220 posts
Posted November 28, 2020
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.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • blubb
      My forge server wont make a mods folder

      By blubb · Posted 50 minutes ago

      I got it working Im not sure why but if I had to guess its because I cleaned up my desktop into 2 neat folders and suddenly it works
    • blubb
      My forge server wont make a mods folder

      By blubb · Posted 1 hour ago

      No
    • DaemonUmbra
      My forge server wont make a mods folder

      By DaemonUmbra · Posted 1 hour ago

      Are you renaming any files after reinstalling?
    • blubb
      My forge server wont make a mods folder

      By blubb · Posted 1 hour ago

      Also after that I looked and they where all gone and I tried again but still didn't work
    • blubb
      My forge server wont make a mods folder

      By blubb · Posted 2 hours ago

      Sorry for the late reply but I did that and it was the same thing for all of them
  • Topics

    • blubb
      36
      My forge server wont make a mods folder

      By blubb
      Started 5 hours ago

    • ZDOG22
      0
      [1.16.4] Remove Minecraft Pitch Limit

      By ZDOG22
      Started 4 hours ago

    • Eridani
      0
      Best way to create a new dye.

      By Eridani
      Started 4 hours ago

    • djsweely
      1
      SERVER CRASH

      By djsweely
      Started 4 hours ago

    • Luis_ST
      1
      [1.16.5] Help with custom Glass Block

      By Luis_ST
      Started Friday at 07:35 AM

  • Who's Online (See full list)

    • Choonster
    • sarkozi
    • SwiftServices
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Making a pumpkin like overlay (1.16.4)
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community