Jump to content

[1.6.1] RenderGameOverlay creates lighting issues


BluSunrize

Recommended Posts

Heyo!

 

I've experimented a bit with events and rendering and decided to tap into the RenderGameOverlayEvent so render an arrow counter for my custom bow.

It works by displaying the icon of the arrow over the icon of the bow and is only displayed when the bow is selected.

 

However, when I select the bow, the text in chat and the text displaying what item was selected darkens. I believe that it has something to do with disabling and enabling various GL11 options, but I have been unable to figure out which.

 

The code is as folows:

public void render(RenderGameOverlayEvent event)
{
if(event.isCancelable() || event.type != ElementType.HOTBAR)
{      
	return;
}
ScaledResolution rez = event.resolution;
int xPos = 2;
int yPos = 2;
EntityPlayer player = this.mc.thePlayer;
if(player.getCurrentEquippedItem()!=null&&player.getCurrentEquippedItem().itemID==BluTechnology.ItemStandardBow.itemID)
{		
	GL11.glPushMatrix();
	RenderHelper.enableGUIStandardItemLighting();
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glEnable(GL12.GL_RESCALE_NORMAL);
	GL11.glEnable(GL11.GL_COLOR_MATERIAL);
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_DEPTH_TEST);			
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	int meta = player.getCurrentEquippedItem().getItemDamage();
	//Ignore the method getArrows(), it simply returns an integer of how many arrows of the type are in the inventory of the player			
	ItemStack ammo = new ItemStack(BluTechnology.ItemArrowparts,getArrows(player,meta),meta+1);
	int hbStart = ((rez.getScaledWidth()/2)-91);

	itemRenderer.zLevel = 100.0F;
	itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, ammo, (player.inventory.currentItem*20)+hbStart+3, rez.getScaledHeight()-54);
	itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, ammo, (player.inventory.currentItem*20)+hbStart+6, rez.getScaledHeight()-55);
	GL11.glPopMatrix();
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDisable(GL11.GL_COLOR_MATERIAL);
	RenderHelper.enableStandardItemLighting();
}
}

 

Anyone see what I'm going for and what I'm doing wrong?

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.