KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
678 stars 103 forks source link

Gradient tags in combination with length modifying tags #1045

Open CubBossa opened 4 months ago

CubBossa commented 4 months ago

Assuming there were a <repeat:_amount_> tag, a wrapping gradient tag would not be able to apply its gradient correctly scaled on the repeated content.

The code that I used for the repeat tag to reproduce this was

return (Modifying) (current, depth) -> {
    if (depth > 0) return Component.empty();
    Component c = Component.empty();
    for (int i = 0; i < count; i++) {
        c = c.append(current);
    }
    return c;
}

Against what I expected, <gradient:black:dark_gray:black><repeat:12>-</repeat><slot/> produced gradients scaled on <slot/>#length + 1 only grafik

From what code I found online, it looks like gradient tags only take child Inserting tags into account and not child Modifying tags. https://github.com/KyoriPowered/adventure/blob/aeaeb9939b3bddc66c219f66e1fe43b997c9d41a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/tag/standard/AbstractColorChangingTag.java#L82