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    77

Beethoven92

Beethoven92    77

  • Dragon Slayer
  • Beethoven92
  • Members
  • 77
  • 605 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    7705

diesieben07

diesieben07    7705

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7705
  • 56508 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    7705

diesieben07

diesieben07    7705

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7705
  • 56508 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    57

vemerion

vemerion    57

  • Creeper Killer
  • vemerion
  • Members
  • 57
  • 222 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

    • LessyDoggy
      Forge 1.12.2 Installing Bug

      By LessyDoggy · Posted 41 minutes ago

      So I used forge 1.16.5 but now I cant change it too 1.12.2 no mather what. I have tried Installing client, Installing server and extract but nothing works. I even removed forge 1.16.5 from my computer but I still have that verison on and idk how to change it.
    • Yourskillx2
      !!Keeps crashing during launch!!

      By Yourskillx2 · Posted 59 minutes ago

      I have a decent sized mod pack with around 90 mods and every time I go to launch the game, it loads some stuff then crashes with exit code 0, I cannot figure out if its a mod in the pack doing it, like maybe not a release version or if it just doesn't work with Mc like its supposed to.
    • IMaironI
      server error

      By IMaironI · Posted 7 hours ago

      2021-03-06-8.log
    • diesieben07
      server error

      By diesieben07 · Posted 7 hours ago

      Like I already said: The logs folder.
    • prototype204
      Attacking/Hitting issue

      By prototype204 · Posted 7 hours ago

      I am no longer able to attack animals or mobs in the game, however they are still able to attack me. I checked to verify that the mods I downloaded weren't the issue. I think they might be an error code in forge 1.16.5 however if anyone knows what I could do to fix this. P.S. I could still break bricks. 
  • Topics

    • LessyDoggy
      0
      Forge 1.12.2 Installing Bug

      By LessyDoggy
      Started 41 minutes ago

    • Yourskillx2
      0
      !!Keeps crashing during launch!!

      By Yourskillx2
      Started 59 minutes ago

    • IMaironI
      13
      server error

      By IMaironI
      Started 11 hours ago

    • prototype204
      0
      Attacking/Hitting issue

      By prototype204
      Started 7 hours ago

    • BeardlessBrady
      3
      [1.16.5] Adding arguments to DeferredRegister and RegistryObject

      By BeardlessBrady
      Started 11 hours ago

  • Who's Online (See full list)

    • P3pp3rF1y
    • zlappedx3
  • 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