Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

(1.16.5 MCP) Render overlay error(background black)


ElTotisPro50
 Share

Recommended Posts

so im rendering an icon FROM A .PNG IMAGE, and is doing it well but the background of the icon is black when I change what i have in my hand, this is not TOO bad but if i want to render a image that covers the entire screen every time i select a diferent item the background will turn black(MY IMAGE IS .PNG AND THE BACKGROUND IS NOT BLACK)

 

https://imgur.com/a/M0KgTaG (from imgur the background looks black but download the image and open it in a photo editor and you will see that is transparent)

 

public static final ResourceLocation ICONS = new ResourceLocation(TotisMod.MOD_ID,"textures/gui/icons.png");

@SubscribeEvent
    public static void renderOverlay(RenderGameOverlayEvent event) //i cant use .Pre or .Post because the survival hunger and health bars will bug
    {
        Minecraft mc = Minecraft.getInstance();
        if(event.getType() == RenderGameOverlayEvent.ElementType.TEXT) //if i use .ALL the background will ALWAYS be black and i HAVE to put this if statement or hunger and health bars will bug
        {
            mc.getTextureManager().bindTexture(ICONS);
            drawTexturedModalRect(0,0,144,0,16,16,1); //i tried to put for example 100 and 0 in Z level but apparently it doesnt change anything
        }
    }

 

Link to comment
Share on other sites

To draw something on the HUD you must use RenderGameOverlayEvent.Post with ElementType.ALL. Subscribing to a parent event class (like RenderGameOverlayEvent) directly almost never achieves useful results.

When drawing on the HUD with a different texture, you must switch back to the normal HUD texture (AbstractGui.GUI_ICONS_LOCATION) afterwards.

Link to comment
Share on other sites

4 hours ago, diesieben07 said:

To draw something on the HUD you must use RenderGameOverlayEvent.Post with ElementType.ALL. Subscribing to a parent event class (like RenderGameOverlayEvent) directly almost never achieves useful results.

When drawing on the HUD with a different texture, you must switch back to the normal HUD texture (AbstractGui.GUI_ICONS_LOCATION) afterwards.

where i put AbstractGui.ICONS, and what do you mean with "subscribing to a parent event class", is like this?

@SubscribeEvent
public static void render1(RenderGameOverlayEvent.Post event)
{
		Minecraft mc = Minecraft.getInstance();
        if(event.getType() == RenderGameOverlayEvent.ElementType.ALL)
        {
            mc.getTextureManager().bindTexture(ICONS);
            drawTexturedModalRect(0,0,144,0,16,16,1);
        }
}

@SubscribeEvent
public static void render2(RenderGameOverlayEvent.Post event)
{
		render1()
		AbstractGui.ICONS;
}

 

Link to comment
Share on other sites

1 minute ago, ElTotisPro50 said:

where i put AbstractGui.ICONS

After rendering your stuff, bind that texture.

1 minute ago, ElTotisPro50 said:

and what do you mean with "subscribing to a parent event class"

RenderGameOverlayEvent is the parent class for RenderGameOverlayEvent.Pre and RenderGameOverlayEvent.Post. If you subscribe RenderGameOverlayEvent, you'll receive all subclasses, which is usually not useful at all.

2 minutes ago, ElTotisPro50 said:

is like this?

Why do you have two event handlers now? Why is one calling the other? Nothing of this makes any sense.

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

After rendering your stuff, bind that texture.

RenderGameOverlayEvent is the parent class for RenderGameOverlayEvent.Pre and RenderGameOverlayEvent.Post. If you subscribe RenderGameOverlayEvent, you'll receive all subclasses, which is usually not useful at all.

Why do you have two event handlers now? Why is one calling the other? Nothing of this makes any sense.

dude you didnt explained me anything, "After rendering your stuff, bind that texture.", what does that mean??? i put drawTexturedModalRect and AFTER THAT mc.getTextureManager().bindTexture(ICONS);?? and you didnt tell me where i put the abstract gui thingy, and you told me to parent RenderGameOverlayEvent

 

AbstractGui.GUI_ICONS_LOCATION; what is this how i implement this

Edited by ElTotisPro50
Link to comment
Share on other sites

Just now, ElTotisPro50 said:

"After rendering your stuff, bind that texture.", what does that mean???

You already know how to bind a texture (I mean, you are binding your own texture... so I assumed you know...). So I don't really know what else to explain here.

1 minute ago, ElTotisPro50 said:

i put drawTexturedModalRect and AFTER THAT mc.getTextureManager().bindTexture(ICONS);??

Yes.

1 minute ago, ElTotisPro50 said:

and you didnt tell me where i put the abstract gui thingy, and you told me to parent RenderGameOverlayEvent

What?

Link to comment
Share on other sites

59 minutes ago, diesieben07 said:

You already know how to bind a texture (I mean, you are binding your own texture... so I assumed you know...). So I don't really know what else to explain here.

Yes.

What?

parenting RenderGameOverlayEvent, what does that mean

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

You already know how to bind a texture (I mean, you are binding your own texture... so I assumed you know...). So I don't really know what else to explain here.

Yes.

What?

@SubscribeEvent
    public static void renderOverlay(RenderGameOverlayEvent.Post event)
    {
        Minecraft mc = Minecraft.getInstance();
        GuiUtils gui = new GuiUtils();
        if(event.getType() == RenderGameOverlayEvent.ElementType.ALL)
        {
            drawTexturedModalRect(0,0,144,0,16,16,0);
            mc.getTextureManager().bindTexture(ICONS);
        }
    }

it DIDNT WORK

Link to comment
Share on other sites

18 minutes ago, ElTotisPro50 said:

parenting RenderGameOverlayEvent, what does that mean

I have not said this. I used the term "parent" and "parent class". If you do not know what these means, you need to learn Java basics.

14 minutes ago, ElTotisPro50 said:

it DIDNT WORK

Why are you making a random GuiUtils instance?

Why are you no longer binding your own texture?

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

I have not said this. I used the term "parent" and "parent class". If you do not know what these means, you need to learn Java basics.

Why are you making a random GuiUtils instance?

Why are you no longer binding your own texture?

im binding my texture, ICONS is my texture:

public static final ResourceLocation ICONS = new ResourceLocation(TotisMod.MOD_ID,"textures/gui/icons.png")

the random GuiUtil instance is because is for another thing ignore it, then why is not working is showing me like the texture of the hearts that you have when the wither affects you?(like the black hearts) but only one and a half because i said that the texture is 16x16

Link to comment
Share on other sites

6 hours ago, diesieben07 said:

You have to first bind your texture. Then render your stuff. Then bind the vanilla icons texture again, because that is what the rest of the HUD code expect. The vanilla hud texture is AbstractGui.ICONS.

It worked!!!(you could have told me just that instead of "subscribing parenting RenderGameOverlayEvent" and that things)

 

this is the code that works:

@SubscribeEvent
    public static void renderOverlay(RenderGameOverlayEvent.Post event)
    {
        Minecraft mc = Minecraft.getInstance();

        if(event.getType() == RenderGameOverlayEvent.ElementType.ALL)
        {
            mc.getTextureManager().bindTexture(ICONS);
            drawTexturedModalRect(0,0,144,0,16,16,0);
            mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
        }
    }

 

Link to comment
Share on other sites

59 minutes ago, diesieben07 said:

I... did?

To draw something on the HUD you must use RenderGameOverlayEvent.Post with ElementType.ALL. Subscribing to a parent event class (like RenderGameOverlayEvent) directly almost never achieves useful results.

When drawing on the HUD with a different texture, you must switch back to the normal HUD texture (AbstractGui.GUI_ICONS_LOCATION) afterwards.

you should have said different words, instead of "switch back to the normal HUD TEXTURE AbstractGui.ICONS",        "bind your Icons,draw your stuff and bind AbstractGui.ICONS", I could have understood that perfectly because you didnt say me BIND AbstractGui just SWITCH, i know it sound stupid but idk is easier even is an overlay is not so basic

Link to comment
Share on other sites

On 1/16/2022 at 11:27 AM, diesieben07 said:

I... did?

hi, im here againt because i need something, the all my overlays are 256x256, even those from some overlay tutorials, but i've seen some people that uses overlays of 1920x1080 and i tried but it kind of duplicate (my overlays of 256x256 works)

 

(1920x1080)

this is how it should look: https://imgur.com/a/p8pXEzn

and this is how IT LOOKS: https://imgur.com/a/4F35AAP

mc.getTextureManager().bindTexture(textureLocation);
//gui.drawTexturedModalRect(x, y, imageOffsetX, imageOffsetY, imageSizeX, imageSizeY,zLevel);
gui.drawTexturedModalRect(x, y, 0, 0, 1920, 1080,100);
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);

 

Edited by ElTotisPro50
Link to comment
Share on other sites

12 hours ago, poopoodice said:

You have to declare the dimension of the texture, the default value is 256x256 (from the method you are using)

dude see me code, drawTexturedModalRect(X,Y,IMAGEOFFSETX,IMAGEOFFSETY,1920,1080,ZLEVEL)

with drawTexturedModalRect the max size of the image is 1920x1080?, what method should i use

Link to comment
Share on other sites

drawTexturedModalRect assumes that by default your texture is 256x256. There are variants that let you specify the total texture size (as opposed to just the part you want to draw) as well. You need to do use those if you want a texture that is not 256x256. Note also that your texture file should be a power of 2.

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

drawTexturedModalRect assumes that by default your texture is 256x256. There are variants that let you specify the total texture size (as opposed to just the part you want to draw) as well. You need to do use those if you want a texture that is not 256x256. Note also that your texture file should be a power of 2.

which method i have to use, there are a lot and i only learned drawTexturedModalRect

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

It's also called drawTexturedModalRect, just with more parameters.

there are only 2 drawTexturedModalRect, the ONLY DIFFERENCE between those 2 is that one has a MatrixStack at the beginning, 

The one i use for 256x256
public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)

the one u told me (do i have to use this one right?)
public static void drawTexturedModalRect(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel)

 

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

It's also called drawTexturedModalRect, just with more parameters.

it didnt work: 

MatrixStack stack = new MatrixStack();
mc.getTextureManager().bindTexture(textureLocation);
gui.drawTexturedModalRect(stack,x, y, imageOffsetX, imageOffsetY, imageSizeX, imageSizeY,zLevel);
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);

 

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

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • server failed to start and gives me "Failed to load data packs, can't proceed with server load. You can either fix your data packs or reset to vanilla with --safeMode" error when i look in my logs. its updated to the latest version of forge(40.1.0), and I don't have any data packs installed as far as I know. And I will upload the full logs if asked as i dont know how to attach a document to this post.  
    • Pioneer Craft [modded] {1.18.2} {SMP} {Community} {Light Roleplay} We are Pioneer Craft and we seek you !!! We are building a community of passionate players to build, trade, and share some laughs with. Are you tired of playing alone? Or are you here seeking a server with dedicated members; a server where you are not overlooked and can voice your opinions? If you are interested in these things too, then come join us in Pioneer Craft! Our server is player built and driven. We have a custom mod pack with mods chosen by our community to suit our needs. We have designed our server for player driven roleplay! There will be four communities which will each be self-sufficient. We encourage and seek builders who want to create a beautiful world to live in. This is a whitelist server and we are looking for dedicated applicants and experienced builders. Applications are located on our website which can be accessed through the discord. Other than the application questions, we are requesting photos of your prior builds which will be taken into consideration. Please show photos of your builds in the share-your-work section of the discord. The server uses CurseForge to run. This server is for mature members (16+) . Discord (must join): https://discord.gg/c4uJvb29CN
    • Pioneer Craft [modded] {1.18.2} {SMP} {Community} {Light Roleplay} We are Pioneer Craft and we seek you !!! We are building a community of passionate players to build, trade, and share some laughs with. Are you tired of playing alone? Or are you here seeking a server with dedicated members; a server where you are not overlooked and can voice your opinions? If you are interested in these things too, then come join us in Pioneer Craft! Our server is player built and driven. We have a custom mod pack with mods chosen by our community to suit our needs. We have designed our server for player driven roleplay! There will be four communities which will each be self-sufficient. We encourage and seek builders who want to create a beautiful world to live in. This is a whitelist server and we are looking for dedicated applicants and experienced builders. Applications are located on our website which can be accessed through the discord. Other than the application questions, we are requesting photos of your prior builds which will be taken into consideration. Please show photos of your builds in the share-your-work section of the discord. The server uses CurseForge to run. This server is for mature members (16+) . Discord (must join): https://discord.gg/c4uJvb29CN 
    • Update: I didn't need capabilities. In fact, I didn't need to override applyEffectTick at all. But it seems like I need reflections. The increased hitbox size now works for both entity and block collision--with a little drawback. This is what it looks like so far: // this event handler checks every tick if the living entity has the "big" effect @SubscribeEvent public static void entitySizeChange(LivingEvent.LivingUpdateEvent event) { LivingEntity livingEntity = event.getEntityLiving(); if (livingEntity.getActiveEffectsMap() != null && livingEntity.hasEffect(ModEffects.BIG.get())) { EntityDimensions newDims = livingEntity.getDimensions(livingEntity.getPose()).scale(8.0F, 2.0F); try { // using reflection Field field = Entity.class.getDeclaredField("dimensions"); field.setAccessible(true); field.set(livingEntity, newDims); // setting the living entity's EntityDimensions EntityDimensions newEntityDimensions = (EntityDimensions) field.get(livingEntity); livingEntity.setBoundingBox(newEntityDimensions.makeBoundingBox( // setting the living entity's AABB livingEntity.getX(), livingEntity.getY(), livingEntity.getZ() )); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } } }   The aforementioned drawback is that, when the effect wears off, the living entity's still keeps its bigger hitbox until it changes pose (i.e. my player crouching). Given that the EntityEvent.Size event fires whenever an entity changes pose, should I manually fire it with EVENT_BUS::post when that entity's effect wears off? If so, where? I tried manually firing EntityEvent.Size on my overridden removeAttributeModifiers(), but to no avail. 
    • I'm working with very limited recourses on my PC so I wish this graph worked properly I allowed 3gbs when I created the server and now decided to bump it up to 6G's I'm having the same issue as OP there is no update on the GUI itself that says so, it gets to 1% free and seems to stop at 2800ish MB's of space and the entire server starts to lag. This is extremely frustrating I've looked around the internet and can't seem to find ANY fix about this. My user_jvm_args file looks as so. # Xmx and Xms set the maximum and minimum RAM usage, respectively. # They can take any number, followed by an M or a G. # M means Megabyte, G means Gigabyte. # For example, to set the maximum to 3GB: -Xmx3G # To set the minimum to 2.5GB: -Xms2500M # A good default for a modded server is 4GB. # Uncomment the next line to set it. -Xmx4G -Xms2G I read on reddit that adding an Xms command at the end fixed it for someone but it didn't for me at all.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.