Jump to content

[1.11] Rendering an Textured Overlay


Lambda

Recommended Posts

Hello there,

 

So I'm having issues with rendering over the game with a texture, however, I cannot figure out how to draw the texture, this , for example didnt work :

    @SubscribeEvent
    public static void onRenderGameOverlay(RenderGameOverlayEvent event) {
        final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_mana_bar");
        Minecraft mc = Minecraft.getMinecraft();
        if(!event.isCanceled() && event.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
            CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null);
            mc.renderEngine.bindTexture(RES_LOC);
            mc.ingameGUI.drawTexturedModalRect(mc.displayWidth / 2, mc.displayHeight / 2, 0, 0, 111, 9);
        }
    }

 

Thanks,

 

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Link to comment
Share on other sites

Why do people keep checking

event.isCancelable()

?  That's only ever going to return true or false based on the event class and won't ever change.  Are you mistaking it for

event.isCanceled()

?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I don't see anything obvious, but it's been a while since I tried to render any GUI stuff.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

With the event you're using you can use "event.getResolution();"

 

which is a ScaledResolution object.

 

from there you can create a middle X, far X, middle Y, and lowest Y

 

		ScaledResolution res = event.getResolution();
	int bottomScreen = res.getScaledHeight(), 
			halfHeight = bottomScreen / 2;
	int rightScreen = res.getScaledWidth(), 
			halfWidth = rightScreen / 2;

 

then you can just draw what you want based off of that. And screen size (the game window size) and GUI Scale (Video Setting)

 

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.



×
×
  • Create New...

Important Information

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