Jump to content

[1.8] Render Overlay on Key Press


HassanS6000

Recommended Posts

What I'm trying to do, is that on the press of a key, in this case, Z an overlay appears if you're holding an item. I know everything up until the rendering works. However, when it tries to render, my method for finding the xPos and yPos to start drawing my Rectangle gets screwed up, and goes into negatives, and even when it's not in negatives, it won't render.

 

Here's my code for KeyInputHandler: http://pastebin.com/JNNVSnDu

Here's what the numbers are coming up as:

Scaled Width: 427

Scaled Height: 240

X-Pos 299

Y-Pos 112

 

And it doesn't render. Any help would be greatly appreciated! Thanks in Advance :D

Link to comment
Share on other sites

Big mistake: (accssing) Proper way:

int w = event.resolution.getScaledWidth();
int h = event.resolution.getScaledHeight();

 

And again - you are doing it wrong. Rendering ANYTHING onto overlay SHOULD happen in GuiRenderGameOverlayEvent.

http://www.minecraftforge.net/wiki/Key_Binding

After you have you KeyBinding object , you can chk for it's "isPressed" or something like it. Then you can use this variable inside GRGOEvent. Inside that event (overlay), you call code I gave you above.

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

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.

Announcements



×
×
  • Create New...

Important Information

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