Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.