Jump to content

Having problems with Chat box overlaping / clearing HUD gui ingame graphics


Jade_Knightblazer

Recommended Posts

Been having a problem with this some time now. Normally it didn't really hurt anything however with a new hud I created the chat box is becoming problematic...

 

The Issue: If new text is placed in the chat box, all my render tick GUI elements get covered up. This is problematic when the Hud provides a resource pool. Below is my example:

 

*Normal*

asexampleguiproblem.png

 

*Chat covering up hud*

asexampleguiproblem2.png

 

The code I use (Relative to issue): ClientTickHandlerAsgardShield

 

 

public final class ClientTickHandlerAsgardShield implements ITickHandler
{
int ASGuardGuage = 0;
boolean ASGuardGuageGilded = false;

@Override
    public void tickStart(EnumSet<TickType> type, Object... tickData) {}

    @Override
    public void tickEnd(EnumSet<TickType> type, Object... tickData)
    {
        if (type.equals(EnumSet.of(TickType.RENDER)))
        {
            onRenderTick();
        }
        else if (type.equals(EnumSet.of(TickType.CLIENT)))
        {
            GuiScreen guiscreen = Minecraft.getMinecraft().currentScreen;
            if (guiscreen != null)
            {
                onTickInGUI(guiscreen);
            } else {
                onTickInGame();
            }
        }
    }

    @Override
    public EnumSet<TickType> ticks()
    {
        return EnumSet.of(TickType.RENDER, TickType.CLIENT);
        // In my testing only RENDER, CLIENT, & PLAYER did anything on the client side.
        // Read 'cpw.mods.fml.common.TickType.java' for a full list and description of available types
    }

    @Override
    public String getLabel() { return null; }


    public void onRenderTick()
    {
    	Minecraft mc = FMLClientHandler.instance().getClient();
    	if (mc.thePlayer == null || mc.theWorld == null) return;
    	{
    		EntityPlayer p = mc.thePlayer;
    	
    		//System.out.println("onRenderTick");
    		//TODO: Your Code Here
    		
    		//FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("VC "+ItemAsgardShield.asgardShieldVanguardCountI, 0, 0, 16777215);
    		
    		//Vanguard GUI
    		if (p.isBlocking() && ItemAsgardShield.asgardShieldActive == true && mc.playerController.isInCreativeMode() == false)
    		{
    			ScaledResolution var5 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    		    int var6 = var5.getScaledWidth();
    		    int var7 = var5.getScaledHeight();
    			int texture = mc.renderEngine.getTexture("/mod_AsgardShield/AsgardShieldTex/VCGauge.png");
    			mc.renderEngine.bindTexture(texture);
    			int VCCharge = (ItemAsgardShield.asgardShieldVanguardCountI * 16) - 16;
    			if(VCCharge < 0){VCCharge = 0;}
    			FMLClientHandler.instance().getClient().ingameGUI.drawTexturedModalRect(var6 / 2 - 8, var7 - 54, VCCharge, 0, 16, 16);
    		}
    		
    		//Guard Gauge GUI
    		if (mod_AsgardShield.guardGaugeActive == true && mc.playerController.isInCreativeMode() == false)
    		{
    			int var18;
    			int var26;
    			int total;
    			int gilded;
    			total = this.ASGuardGuage / 20;
    			if (this.ASGuardGuageGilded == true){gilded = 9;}else{gilded = 0;}
    			
    			for (int var25 = 0; var25 < 10 - total; ++var25)
                {
    				ScaledResolution var5 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    				int var6 = var5.getScaledWidth();
    				int var7 = var5.getScaledHeight();
    				int ggTexture = mc.renderEngine.getTexture("/mod_AsgardShield/AsgardShieldTex/GuardGauge.png");
    				mc.renderEngine.bindTexture(ggTexture);
    			
    				var18 = var6 / 2 + 82;
    				var26 = var18 - var25 * 8;
    				
    				FMLClientHandler.instance().getClient().ingameGUI.drawTexturedModalRect(var26, var7 - 49, gilded, 0, 9, 9);
                }
    		}
    	}
    }
}

 

 

Link to comment
Share on other sites

Hmm, have you tried something like this? I did something like this ages ago and I never experienced those problems with this method.

 

@Override

    public void tickEnd(EnumSet<TickType> type, Object... tickData)

    {

        ScaledResolution scaledresolution = new ScaledResolution(

        mc.gameSettings, mc.displayWidth, mc.displayHeight);

        int width = scaledresolution.getScaledWidth();

        int height = scaledresolution.getScaledHeight();

        FontRenderer fontrenderer = mc.fontRenderer;

        mc.entityRenderer.setupOverlayRendering();

       

        // render

}

Link to comment
Share on other sites

The single line of mc.entityRenderer.setupOverlayRendering(); seems to do the trick :) However it doesn't fade/transparent itself like the rest of the Gui Elements.

 

Going to check deeper into Minecrafts GUI ingame, to see if/where the alpha render is at.

 

Thank you sooo very much for giving me a proper place to start looking :D

Link to comment
Share on other sites

I sorta figured it out a back way....

 

I placed this at the very start of my renderTick end()

 

GuiScreen guiscreen = Minecraft.getMinecraft().currentScreen;
    		if (guiscreen == null || mc.ingameGUI.getChatGUI().getChatOpen())
    		{

 

This way if any GUI is open, the custom hud will not render. However the hud still renders on top the chat window :D

 

Thanks for your help Sir!

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.