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
  • 556 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    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 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    7587

diesieben07

diesieben07    7587

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7587
  • 54935 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

    • Rollng
      Game crashes while loading world

      By Rollng · Posted 2 minutes ago

      Whenever i try to enterlatest.log my world game closes itself. Heres crash report and log :crash-2021-01-17_18.09.13-server.txtlatest.log  
    • Linky132
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132 · Posted 25 minutes ago

      I figured it out. I had the render type set to translucent, when what it should have been on was cutout. Thanks for the help.
    • Klarks
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks · Posted 50 minutes ago

      So what needs to be implemented? My Entity?  
    • Linky132
      (1.16.2) Making a new capability (3)

      By Linky132 · Posted 1 hour ago

      I could be wrong, but I think you might need to add this code in the constructor: FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); And you may need to change the setup method to non-static.
    • Linky132
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132 · Posted 1 hour ago

      Also, the texture doesn't glitch when the dust is in a straight line, or when it's in its dot form (not the '+' shape).
  • Topics

    • Rollng
      0
      Game crashes while loading world

      By Rollng
      Started 3 minutes ago

    • Linky132
      4
      [SOLVED] [1.16.5 ] Dust Block Texture Glitch

      By Linky132
      Started 18 hours ago

    • Klarks
      12
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks
      Started 18 hours ago

    • e2rifia
      13
      (1.16.2) Making a new capability (3)

      By e2rifia
      Started 6 hours ago

    • Somonestolemyusername
      18
      [1.15.2] How Would I make a custom bow?

      By Somonestolemyusername
      Started Tuesday at 09:30 PM

  • Who's Online (See full list)

    • Rollng
    • Linky132
    • scorpin1
    • Somonestolemyusername
    • Klarks
    • Sensenmann
    • JoB76205
    • StealthyNoodle
    • Danebi
    • st4s1k
    • TheidenHD
  • 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