Exordium

Exordium

984k Downloads

Unexpected HUD layer removal

Madis0 opened this issue ยท 9 comments

commented
  • Minecraft 1.19
  • Fabric Loader 0.14.8
  • Fabric API 0.57.0
  • FasterGUI 5e25a75
  • OneBar 3.0.0 (my mod)

OneBar shows the bars in layers. In the simplest sense, there is

  • bottom layer (black opaque)
  • health layer (red opaque) and
  • hunger (brown semi-transparent)
  • text (white semi-transparent)

Without FasterGUI it looks like this (note the bar behind the text):

2022-07-24_21 23 42

However, FasterGUI somehow omits the bottom layers, so the hunger layer is displayed as if it had no layers underneath at all:

2022-07-24_21 26 14

Considering that the whole point of the mod is to show various bars in layers, I am not sure how I can resolve this. Any ideas to make it compatible with your mod?

commented

Hm, try printing out the value used for the background. The bright red bar seems to be fine, so maybe the background color(the dark red bar) just managed to get some transparency, that under the normal blend settings doesn't become visible.

commented

I had to enforce a blend mode for the hunger bar due to apple skin using an incorrect blend mode. I guess in the future I can provide an API that allows mod devs to fully take control over the blend mode again, assuming they know what they are doing. Could it be, that the bars contain odd transparency that became visible this way?

commented

Could it be, that the bars contain odd transparency that became visible this way?

I'm not sure what could be "odd" about it. I'm using DrawableHelper.fill with an alpha-enabled color picker from Cloth Config's AutoConfig.

commented

Hmm, I think you misunderstood me a bit.

The dark red segment has the correct color and transparency: -1086445789 aka BF3E2723 (hex ARGB).
However, the layer behind it should be -16777216 aka FF000000 but it is not visible at all. While debugging it still correctly went onto the fill command with the right color parameter, so I'm not sure what else to do here.

Toggling "Enabled Gui" off in the mod obviously fixes it.

commented

Issue can still be reproduced in Exordium v1.0.0

commented

Yea I did nothing to try to combat this. You have to make sure to have the correct blend mode enabled, and then it should just work.

commented

So how do I change the blend mode? Don't see an user-facing option for it and don't know what I should do in code. Can I even do it with the DrawableHelper?

commented

No clue about the DrawableHelper. https://github.com/tr7zw/Exordium/blob/1.19/Shared/src/main/java/dev/tr7zw/exordium/ExordiumModBase.java#L164 You probably want to set up these settings to have the correct alpha blending enabled.

commented

Solved by adding the following to my mod:

In build.gradle:

//...
repositories {
        //...
	maven {
		name = "Modrinth"
		url = "https://api.modrinth.com/maven"
		content {
			includeGroup "maven.modrinth"
		}
	}
}
//...
dependencies {
        //...
	modImplementation "maven.modrinth:exordium:1.0.1-1.19"
}

In main code:

import com.mojang.blaze3d.systems.RenderSystem;
import dev.tr7zw.exordium.ExordiumModBase;
//...

public void render(){
            if(doesClassExist("dev.tr7zw.exordium.ExordiumModBase")) {
                ExordiumModBase.correctBlendMode();
                ExordiumModBase.setForceBlend(true);
            }

            // Mod's rendering code here

            if(doesClassExist("dev.tr7zw.exordium.ExordiumModBase")) {
                ExordiumModBase.setForceBlend(false);
                RenderSystem.defaultBlendFunc();
            }
        }
    }

public static boolean doesClassExist(String name) {
		try {
			if(Class.forName(name) != null) {
				return true;
			}
		} catch (ClassNotFoundException e) {}
		return false;
	}
//...