Визуальная часть FontRender Color Items MCP 1.16.5

Ну да 1 литеру изменить - ваще никак не фиксится)))))))))))))))))))))))))
 
(класс рендера фонта):
Expand Collapse Copy
  public static final Color aqua = new Color(0x55FFFF);
    public static final Color light_purple = new Color(0xFF55FF);
    public static final Color yellow = new Color(0xFFFF55);
    public static final Color white = new Color(0xFFFFFF);

private float drawStyledComponent(Matrix4f matrix4f, ITextComponent textComponent, ItemStack stack, float f, float f2, int n) {
        if (textComponent == null) {
            return 0.0f;
        }
        Style style = textComponent.getStyle();

        //пот
        Color rarity = switch (stack.getRarity()) {
            case COMMON -> white;
            case UNCOMMON -> yellow;
            case RARE -> aqua;
            case EPIC -> light_purple;
        };

        int defaultColor = style.getColor() == null ? rarity.getRGB() : ColorUtils.setAlpha(-16777216, n) | ColorUtils.setAlpha(style.getColor().getColor(), n);

        int currentColor = defaultColor;

        String text = textComponent.getSiblings().isEmpty()
                ? textComponent.getString()
                : textComponent.getUnformattedComponentText();
        char[] chars = text.toCharArray();

        for (int i = 0; i < chars.length; ++i) {
            char currentChar = chars[i];
            if (currentChar == '§' && i + 1 < chars.length) {
                char formatChar = Character.toLowerCase(chars[i + 1]);
                TextFormatting format = TextFormatting.fromFormattingCode(formatChar);
                if (format != null) {
                    if (format.isColor()) {
                        currentColor = 0xFF000000 | format.getColor();
                    } else if (format == TextFormatting.RESET) {
                        currentColor = defaultColor;
                    }
                    ++i;
                    continue;
                }
            }
            Glyph glyph = this.locateGlyph(currentChar);
            if (glyph != null &&  /*модер пи^^^*/ glyph.value() != ' ') {
                ResourceLocation texture = glyph.owner().bindToTexture;
                DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
                this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
            }
            if (glyph != null) {
                f += (float)glyph.width();
            }
        }

        if (!textComponent.getSiblings().isEmpty()) {
            for (ITextComponent sibling : textComponent.getSiblings()) {
                f = this.drawStyledComponent(matrix4f, sibling, stack, f, f2, n);
            }
        }

        return f;
    }


тутор как юзать:
Expand Collapse Copy
     Fonts.getSize(14, Fonts.Type.MEDIUM).drawStringItem(
                event.getMatrixStack(),
                displayComponent,
                stack,/* ItemStack stack = itemEntity.getItem();*/
                screenPos.x - totalWidth / 2.0f - 1.0f,
                screenPos.y,  
                0xFFFFFFFF
        );
ss-Посмотреть вложение 308767
надеюсь этот шедевр будет в пасте под именем монотон)
гавно + дрисня + понос ок
 
Очень хорошо, но можно было покороче сделать. Не понял чё людям не понравилось, слили фулл функционал, который просто не подправили визуально, какой ему тогда вообще был бы смысл ему это сюда постить если это как example item name?

:FeelsBadMan: - критиковать может каждый, но не каждый критикует конструктивно..
 
:FeelsBadMan: - критиковать может каждый, но не каждый критикует конструктивно..
Там чел конструктив не воспринимает
Но у меня и к тебе вопрос есть, вот глянь на блок кода ниже, запомни что это делается на рендертреде и подумай, нормально ли это?
Код:
Expand Collapse Copy
Glyph glyph = this.locateGlyph(currentChar);
if (glyph != null && glyph.value() != ' ') {
    ResourceLocation texture = glyph.owner().bindToTexture;
    DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
    this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
}
Если для читов это нормально - снимаю шляпу :roflanPominki:
 
Там чел конструктив не воспринимает
Но у меня и к тебе вопрос есть, вот глянь на блок кода ниже, запомни что это делается на рендертреде и подумай, нормально ли это?
Код:
Expand Collapse Copy
Glyph glyph = this.locateGlyph(currentChar);
if (glyph != null && glyph.value() != ' ') {
    ResourceLocation texture = glyph.owner().bindToTexture;
    DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
    this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
}
Если для читов это нормально - снимаю шляпу :roflanPominki:
это система рендера шрифта,к теме это нахуй не относиться
Там чел конструктив не воспринимает
Но у меня и к тебе вопрос есть, вот глянь на блок кода ниже, запомни что это делается на рендертреде и подумай, нормально ли это?
Код:
Expand Collapse Copy
Glyph glyph = this.locateGlyph(currentChar);
if (glyph != null && glyph.value() != ' ') {
    ResourceLocation texture = glyph.owner().bindToTexture;
    DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
    this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
}
Если для читов это нормально - снимаю шляпу :roflanPominki:
на это можешь не обращать внимание тк это не связано с темой на юг

Glyph glyph = this.locateGlyph(currentChar);
if (glyph != null && glyph.value() != ' ') {
ResourceLocation texture = glyph.owner().bindToTexture;
DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
}
if (glyph != null) {
f += (float)glyph.width();
}
}

if (!textComponent.getSiblings().isEmpty()) {
for (ITextComponent sibling : textComponent.getSiblings()) {
f = this.drawStyledComponent(matrix4f, sibling, stack, f, f2, n);
}
}

return f;
}
 
(класс рендера фонта):
Expand Collapse Copy
  public static final Color aqua = new Color(0x55FFFF);
    public static final Color light_purple = new Color(0xFF55FF);
    public static final Color yellow = new Color(0xFFFF55);
    public static final Color white = new Color(0xFFFFFF);

private float drawStyledComponent(Matrix4f matrix4f, ITextComponent textComponent, ItemStack stack, float f, float f2, int n) {
        if (textComponent == null) {
            return 0.0f;
        }
        Style style = textComponent.getStyle();

        //пот
        Color rarity = switch (stack.getRarity()) {
            case COMMON -> white;
            case UNCOMMON -> yellow;
            case RARE -> aqua;
            case EPIC -> light_purple;
        };

        int defaultColor = style.getColor() == null ? rarity.getRGB() : ColorUtils.setAlpha(-16777216, n) | ColorUtils.setAlpha(style.getColor().getColor(), n);

        int currentColor = defaultColor;

        String text = textComponent.getSiblings().isEmpty()
                ? textComponent.getString()
                : textComponent.getUnformattedComponentText();
        char[] chars = text.toCharArray();

        for (int i = 0; i < chars.length; ++i) {
            char currentChar = chars[i];
            if (currentChar == '§' && i + 1 < chars.length) {
                char formatChar = Character.toLowerCase(chars[i + 1]);
                TextFormatting format = TextFormatting.fromFormattingCode(formatChar);
                if (format != null) {
                    if (format.isColor()) {
                        currentColor = 0xFF000000 | format.getColor();
                    } else if (format == TextFormatting.RESET) {
                        currentColor = defaultColor;
                    }
                    ++i;
                    continue;
                }
            }
            Glyph glyph = this.locateGlyph(currentChar);
            if (glyph != null &&  /*модер пи^^^*/ glyph.value() != ' ') {
                ResourceLocation texture = glyph.owner().bindToTexture;
                DrawEntry drawEntry = new DrawEntry(f, f2, currentColor, glyph);
                this.GLYPH_PAGE_CACHE.computeIfAbsent(texture, k -> new ObjectArrayList<>()).add(drawEntry);
            }
            if (glyph != null) {
                f += (float)glyph.width();
            }
        }

        if (!textComponent.getSiblings().isEmpty()) {
            for (ITextComponent sibling : textComponent.getSiblings()) {
                f = this.drawStyledComponent(matrix4f, sibling, stack, f, f2, n);
            }
        }

        return f;
    }


тутор как юзать:
Expand Collapse Copy
     Fonts.getSize(14, Fonts.Type.MEDIUM).drawStringItem(
                event.getMatrixStack(),
                displayComponent,
                stack,/* ItemStack stack = itemEntity.getItem();*/
                screenPos.x - totalWidth / 2.0f - 1.0f,
                screenPos.y,  
                0xFFFFFFFF
        );
ss-Посмотреть вложение 308767
надеюсь этот шедевр будет в пасте под именем монотон)
Братан, это криво, код дерьмо, реализация дерьмо, время потрачено зря
 

Похожие темы

Назад
Сверху Снизу