Jump to content

Recommended Posts

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.

Posted

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.

Posted

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.

Posted

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?

Posted

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

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

Announcements



×
×
  • Create New...

Important Information

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