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

It seems my RenderGameOverlayEvent isn't rendering, I basically just wanna render a string once the player enters the game:

 

	 @SubscribeEvent
 public void onOverlayRender(RenderGameOverlayEvent.Post event) {

	FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("Yooooooo", 0, 0, 16777215);

}

 

It should be working, but it doesn't, hmm.

  • Author

Registered it with:

FMLCommonHandler.instance().bus().register(new ModEventHandler());

 

Check the element type? I'm a bit new to the minecraft source, can you give me a quick dirty rundown on that? I'm running 1.7.10 btw.

  • Author

That worked thanks a ton! How would i go about updating it when I need to/every tick? Its going to display my armor weight value.

You are probably missing the idea.

This event is called everytime for each overlay phase (HEALTH, CHAT, FOOD, etc.) on every tick frame.

 

You just need to put your code in one of phases.

 

The armour for your player can be pulled from mc.thePlayer.inventory.(...)    (something with main and armour inventory and [.0],[1],[2],[3])

 

i belive your armour weight is saved inside NBT? You simply access it and draw.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

This is what i have under the Render event:

 

FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow(String.format("%.2f", weight), 0, 0, 16777215);

 

NOW, its my understanding i need to only render at a certain phase, because currently it does not display the value of weight, which is for sure being set because my debug shows it! So something not right, whats the setupup for a phase, i know so far its "event.getPhase() == something" but im not sure about the something! Any tips or links to lead me in the right direction?

  • Author

So how do check the phase? is it just Phase.START? When i use:

 

if(event.type == RenderGameOverlayEvent.ElementType.EXPERIENCE)

 

It just replaced the experience bar...

  • Author

Hmm, it still won't update at all in game...

 

public class ModEventHandler {

public float weight;

@SubscribeEvent
public void onEntityUpdate(PlayerTickEvent event) {

	weight = ModArmor.armorCall(event.player);
	event.player.capabilities.setPlayerWalkSpeed(weight);
	System.out.println((ModArmor.armorCall(event.player)));

}

@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent event) {

	if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
		FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow(String.format("%.2f", weight), 0, 0,16777215);
	}
}

}

 

Edit: Nvm i got it working!

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.