Chat Heads

Chat Heads

51M Downloads

Conflict with ModernUI

Gamerbolts opened this issue · 6 comments

commented

Hello,

I have your mod in my modpack PXC Cobblemon for Fabric 1.20.1. I was noticing that having ModernUI on at the same time makes it to where Chat Heads don't appear. Not sure if there is some conflict with the two mods or not. Any help is appreciated :)

commented

This looks like a very similar issue to #114.
Changing Chat Heads' rendering to "Before Line" 'fixes' the issue.
I haven't had much success (only some success) adding compatibility for Caxton, so I'm assuming Modern UI won't be much different.

I just released a new version which forces Before Line rendering when either of those mods are installed, for now.
Definitely better than no chat heads at all.

Leaving this issue open in the hopes of fixing it proper one day.

commented

I don't think this can be solved by Chat Heads alone.

A text can be left-to-right, right-to-left, or a mixture of LTR and RTL. The entire string must be used as input for Bidi analysis to get the directions of the text. Naturally, without a text layout engine, you have no way of knowing where to render the player's head. And if the string is split into parts, then the layout/rendering result of the text will be wrong.

It must be emphasized that in Modern Text, text layout and text rendering are two different processes. Text layout only knows the logical width (advance) of the text, and the pixel width of the text is determined only when rendering.

commented

It's better to check against icyllis.modernui.mc.ModernUIMod.isTextEngineEnabled() instead of isModLoaded(). The method is thread-safe and can be called early (in Mixin plugin).

commented

So I was just adding the check you mentioned (also for icyllis.modernui.mc.forge.ModernUIForge for older Forge-only versions) and while testing stuff and this happened:

Image

This was on Fabric 1.20.1 and it only happens when Emojiful is installed...?!

Something that Emojiful does seems to make Chat Heads compatible with Modern UI - and emojis work as well:
Image
(Though the rendering of the picker window is broken, just like in InnovativeOnlineIndustries/Emojiful#9.)

...

Oh, right... 😅
I forgot I added compatibility with Emojiful a while ago, so that explains why the chat heads appear, but it is still surprising that Emojiful seems to work together with Modern UI and act as a sort of compatiblity layer for Chat Heads.
As far as I can tell Emojiful and Modern UI have no explicit compatibility code for each other (at least GitHub search doesn't return anything) and afaik both are replacing the vanilla text renderer (Emojiful does that here), which sounds like a hard-conflict, so I don't get how they seem to work together - surely something must be fundamentally broken with both mods?

I'm also not sure if I should now whitelist Modern UI when Emojiful is detected. 🤔

commented

ModernUI has two text engines, one is native to ModernUI, and the other is designed for Minecraft (belongs to ModernUI-MC project). Below I will use Modern Text to refer to the text engine designed for Minecraft.

Emojiful uses a subclass of Font to override the default drawInBatch() method, which will trigger Modern Text compatibility code. But this is not at all how Modern Text is expected to work, and it will cause many rendering issues. So actually Modern Text is not compatible with Emojiful.

I don't think we should detect Emojiful, just leave it undefined.

commented

But this is not at all how Modern Text is expected to work, and it will cause many rendering issues. So actually Modern Text is not compatible with Emojiful.

Okay, that's what I thought. No point in trying to add a similar hack to Chat Heads then.

I still wonder if this whole chat head render issue (with Caxton as well) could be solved by splitting up the chat message and rendering it in two parts with the chat head inbetween.

Basically going from something like:
renderString"long text that <head here> needs to be rendered")
To something like this:
renderString("long text that")
renderChatHead()
renderString("needs to be rendered")

For actual text that could be right-to-left (which Caxton seems to support) or contain ligatures this would surely be broken to some degree, but practically speaking, chat messages are virtually always preceeded with the sender name and some "tags", followed by the actual message like this:
[VIP] (super important) <Name> actual message
So splitting it into [VIP] (super important) < and Name> actual message would probably work well enough, don't you think?

Only thing is figuring out how exactly to position the chat head, i.e. the pixel width of the preceeding [VIP] (super important) < text.
Does Modern UI have a way to get that pixel size?

I don't think we should detect Emojiful, just leave it undefined.

I just released 0.13.11 and ended up whitelisting the Emojiful combo, since it seemed to work decentish enough - if you ignore the other obvious compatibility issues.
I didn't mention it in the changelog, so nobody should get the wrong idea - hopefully.