Jump to content

Recommended Posts

Posted

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

 

Posted
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;
}

 

Posted (edited)
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
Posted
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

Posted
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

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

dude at least answer me

Posted
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

Posted
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);
        }
    }

 

Posted
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

Posted (edited)
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
Posted
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

Posted
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

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

 

Posted
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);

 

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

 

Posted
1 hour ago, diesieben07 said:

I guess I remembered the name wrong. It is drawTexturedModalRectWithCustomSizedTexture.

Please try and use a little bit of your own brain, thank you.

oh well then thats nice, with the name you gave me i can try it by myself

Posted (edited)
1 hour ago, diesieben07 said:

I guess I remembered the name wrong. It is drawTexturedModalRectWithCustomSizedTexture.

Please try and use a little bit of your own brain, thank you.

nope it doesnt exist in all GuiUtils class (im in 1.16.5 MCP)

Edited by ElTotisPro50
Posted
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

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } }  
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
    • When i join minecraft all ok, when i join world all working fine, but when i open indentity menu, i get this The game crashed whilst unexpected error Error: java.lang.NullPointerException: Cannot invoke "top.ribs.scguns.common.Gun$Projectile.getDamage()" because "this.projectile" is null crash report here https://paste.ee/p/0vKaf
  • Topics

×
×
  • Create New...

Important Information

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