Jump to content

[1.8] Render a Custom Overlay When Helmet is Equipped


HassanS6000

Recommended Posts

What I want to do, is that when a player is wearing a helmet, a overlay is rendered similar to that of the Halo HUD. However, when trying to render anything, it throws errors which seem to be caused from when I bind the texture. Any help would be appreciated! Thanks in Advance! :D

 

My Armor Code:

 

http://pastebin.com/AtMZ4wxb

 

The Log:

 

http://tny.cz/810eb7a4

 

 

Link to comment
Share on other sites

How can I be more specific? I gave you link to tutorial that gives perfect example on how to use this event.

 

To be more informative I can add:

Tick != FPS

 

Ticks are 20/sec and are used to update game data, while lwjgl works alone just using that data. You can't draw stuff inside ticking methods (like you did there). You need to use RenderGameOverlayEvent and draw your stuff there. That event gives you access to overlay screen and width/height of it.

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

Link to comment
Share on other sites

Okay! I've got some things working but not completely! First off, I was wondering how I would scale the image so it always fits the full screen. Currently it's just set to the size of the image, and if the screen size is larger than the image, the image begins to repeat itself.

 

Here's my code for Event Handler: http://pastebin.com/FxWwCmvh

 

Here are my screenshots:

http://snag.gy/NESzb.jpg

http://snag.gy/pwiPC.jpg

 

ALSO! When I try to check if the armor (Helmet) is equipped (currently the commented out code), the game crashes.

 

Here's my crash report: http://pastebin.com/UDCu6pV3

 

Any help would be greatly appreciated! Thanks! :D

Link to comment
Share on other sites

                        ScaledResolution Scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
                        this.drawNonStandardTexturedRect(xPos, yPos, 0, 0, mc.displayWidth, mc.displayHeight, 420, 250);

You have a variable for a scaled resolution, yet you don't use it. Use this:

                        ScaledResolution Scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
                        this.drawNonStandardTexturedRect(xPos, yPos, 0, 0, Scaled.getScaledWidth(), Scaled.getScaledHeight(), 420, 250);

 

//if (((EntityPlayer)mc.thePlayer).inventory.armorInventory[3].getItem() == halocraft.Main.SpartanHelmet){

Check if inventory.armorInventory[3] != null first

Link to comment
Share on other sites

"ALSO! When I try to check if the armor (Helmet) is equipped (currently the commented out code), the game crashes."

 

- Solution is to first take given slot (slots are ItemStacks array) and check if itemStack != null. Only after that you can get item from non-null ItemStack.

 

Resizing will be simply HARD. If you'd accomplish it in any way, the results will be different on different clients and it might affect how your e.g map (bottom left) is displayed.

 

I suggest auto-aligning image to center and smooth-transition to dark on corners if size is exceeded.

In this case - have look at how vanilla renders viantage or how the close-to-worldd-border effect is being done (the red-shading on borders of screen).

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.