Jump to content

(1.16.5 MCP) Render overlay error(background black)


ElTotisPro50

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

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

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

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

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

1 hour ago, diesieben07 said:

You have not changed anything...?

yeah, the one i used before i told about the 1920x1080 doesnt have the MatrixStack, 

THIS IS WHAT I WAS USING
public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)

THIS IS WHAT YOU TOLD ME(there are only 2 drawTexturedModalRect and you said that i have to use the one with "different parameters, this has an extra parameter which is MatrixStack")
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, poopoodice said:

AbstractGui.blit

   public static void blit(MatrixStack matrixStack, int x, int y, float uOffset, float vOffset, int width, int height, int textureWidth, int textureHeight) {

 

there are 2 new values, int width ant height, i tried to put 1920x1080 and 50x50 but it didnt work, what those values do? i guess is not the size of the image or the offset because them are already defined

 

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have setup a 1.12.2 forge server  occasionally it throws a '[Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 2316ms behind, skipping 46 tick(s)' and a ram usage spike  I have 32gb of ram installed in my pc and on a vanilla server l would normally just make a run.bat file but it is not working   When I launch the run.bat C:\Users\Max\Desktop\1.12.2 server>java -Xmx4G -Xms4G -jar minecraft_server.1.12.2.jar nogui C:\Users\Max\Desktop\1.12.2 server>PAUSE Press any key to continue . . .   The run.bat file contains java -Xmx4G -Xms4G -jar minecraft_server.1.12.2.jar nogui PAUSE Any advice would be appreciated
    • I'm opening the forge 1.8.9 installer properly I click install with the client option selected, it says it installs properly but when I go into my files and also when I go into the minecraft launcher, it's just not there.  JVM info: Oracle Corporation - 1.8.0_431 - 25.431-b10 java.net.preferIPv4Stack=true Found java version 1.8.0_431 Considering minecraft client jar Considering library net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9: Not Downloading {Wrong Side} Considering library net.minecraft:launchwrapper:1.12: Not Downloading {Wrong Side} Considering library org.ow2.asm:asm-all:5.0.3: Not Downloading {Wrong Side} Considering library jline:jline:2.13: Not Downloading {Wrong Side} Considering library com.typesafe.akka:akka-actor_2.11:2.3.3 Considering library com.typesafe:config:1.2.1 Considering library org.scala-lang:scala-actors-migration_2.11:1.1.0 Considering library org.scala-lang:scala-compiler:2.11.1 Considering library org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2 Considering library org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2 Considering library org.scala-lang:scala-library:2.11.1 Considering library org.scala-lang:scala-parser-combinators_2.11:1.0.1 Considering library org.scala-lang:scala-reflect:2.11.1 Considering library org.scala-lang:scala-swing_2.11:1.0.1 Considering library org.scala-lang:scala-xml_2.11:1.0.2 Considering library lzma:lzma:0.0.1: Not Downloading {Wrong Side} Considering library net.sf.jopt-simple:jopt-simple:4.6: Not Downloading {Wrong Side} Considering library java3d:vecmath:1.5.2 Considering library net.sf.trove4j:trove4j:3.0.3 Extracting: /forge-1.8.9-11.15.1.2318-1.8.9-universal.jar To: C:\Users\Ian\AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.8.9-11.15.1.2318-1.8.9\forge-1.8.9-11.15.1.2318-1.8.9.jar That's the installer log and I have no idea if anything is wrong.
    • https://mclo.gs/NQ786zI   I don’t understand what I need to do.
    • I am wanting to give the armour in my mod special properties, but I have no idea how to do so.   For the first armour set I want it to be the case that when the full set is worn it has the properties of a carved pumpkin, making it so you won't aggravate endermen when you look at them.    The second, and presumably harder property is that for the second set I would like it to be the case that when the full set is worn, you can walk over the void without falling. (I was considering using the levitation to accomplish this but I wanted to check beforehand).   Would both of these specialities be achievable for each armour set and how exactly would they both be done? Help would be much appreciated. 
    • I finally got my Forge server up and running thanks to the help of the people on this forum and played fine for a day. Now since I started playing today, the server runs for 20-30 minutes then freezes and kicks everyone out but stays up and running but won't let anyone connect. Here is the latest debug log and crashlog from the server. Thank you for reading & helping   https://gist.github.com/Dwolfwoood/d0410e581c86772694f1d8007431c409   https://gist.github.com/Dwolfwoood/b5d521fd071dbfcc816949924757fef9
  • Topics

×
×
  • Create New...

Important Information

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