<commit_before>package com.lion328.thaifixes;

import net.minecraft.client.gui.fonts.TexturedGlyph;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureManager;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

public class HangingThaiCharacterTexturedGlyph extends TexturedGlyph
{

    private static Field[] parentFields;

    private final char character;

    private HangingThaiCharacterTexturedGlyph(char c)
    {
        super(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
        character = c;
    }

    @Override
    public float getWidth()
    {
        return 0.0f;
    }

    @Override
    public void render(TextureManager p_211234_1_, boolean p_211234_2_, float p_211234_3_, float p_211234_4_,
                              BufferBuilder p_211234_5_, float p_211234_6_, float p_211234_7_, float p_211234_8_,
                              float p_211234_9_)
    {
        super.render(p_211234_1_, p_211234_2_, p_211234_3_, p_211234_4_, p_211234_5_, p_211234_6_, p_211234_7_,
                p_211234_8_, p_211234_9_);
    }

    public static HangingThaiCharacterTexturedGlyph fromParent(TexturedGlyph glyph, char c)
    {
        if (parentFields == null)
        {
            return null;
        }

        HangingThaiCharacterTexturedGlyph ret = new HangingThaiCharacterTexturedGlyph(c);

        for (Field field : parentFields)
        {
            try
            {
                field.set(ret, field.get(glyph));
            }
            catch (IllegalAccessException e)
            {
                ThaiFixes.getLogger().info("Failed to create cloned glyph", e);
                return null;
            }
        }

        ret.field_211240_f -= glyph.getWidth();
        ret.field_211241_g -= glyph.getWidth();

        return ret;
    }

    public static void initialize() throws NoSuchFieldException, IllegalAccessException
    {
        if (parentFields != null)
        {
            return;
        }

        Field modiferField = Field.class.getDeclaredField("modifiers");
        modiferField.setAccessible(true);

        List<Field> filteredFields = new ArrayList<>();

        for (Field field : TexturedGlyph.class.getDeclaredFields())
        {
            int modifier = modiferField.getInt(field);

            if ((modifier & Modifier.STATIC) == Modifier.STATIC)
            {
                continue;
            }

            if ((modifier & Modifier.FINAL) == Modifier.FINAL)
            {
                modiferField.set(field, modifier & ~Modifier.FINAL);
            }

            field.setAccessible(true);
            filteredFields.add(field);
        }

        parentFields = filteredFields.toArray(new Field[]{});
    }
}
<commit_msg>Adjust vertices and UV coordinates to hide placeholder in the texture<commit_after>package com.lion328.thaifixes;

import net.minecraft.client.gui.fonts.TexturedGlyph;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureManager;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

public class HangingThaiCharacterTexturedGlyph extends TexturedGlyph
{

    private static Field[] parentFields;

    private final char character;

    private HangingThaiCharacterTexturedGlyph(char c)
    {
        super(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
        character = c;
    }

    @Override
    public float getWidth()
    {
        return 0.0f;
    }

    @Override
    public void render(TextureManager p_211234_1_, boolean p_211234_2_, float p_211234_3_, float p_211234_4_,
                              BufferBuilder p_211234_5_, float p_211234_6_, float p_211234_7_, float p_211234_8_,
                              float p_211234_9_)
    {
        super.render(p_211234_1_, p_211234_2_, p_211234_3_, p_211234_4_, p_211234_5_, p_211234_6_, p_211234_7_,
                p_211234_8_, p_211234_9_);
    }

    public static HangingThaiCharacterTexturedGlyph fromParent(TexturedGlyph glyph, char c)
    {
        if (parentFields == null)
        {
            return null;
        }

        HangingThaiCharacterTexturedGlyph ret = new HangingThaiCharacterTexturedGlyph(c);

        for (Field field : parentFields)
        {
            try
            {
                field.set(ret, field.get(glyph));
            }
            catch (IllegalAccessException e)
            {
                ThaiFixes.getLogger().info("Failed to create cloned glyph", e);
                return null;
            }
        }

        float posYShift = 0.0f;
        float height = 2.99f;

        if (ThaiUtil.isLowerThaiChar(c))
        {
            posYShift = 6.0f;
            height = 1.99f;
        }

        // X vertices
        ret.field_211240_f -= glyph.getWidth();
        ret.field_211241_g -= glyph.getWidth();

        // Y vertices
        ret.field_211242_h += posYShift;
        ret.field_211243_i = ret.field_211242_h + height;

        // UV coordinates
        ret.v0 += posYShift / 128.0f;
        ret.v1 = ret.v0 + height / 128.0f;

        return ret;
    }

    public static void initialize() throws NoSuchFieldException, IllegalAccessException
    {
        if (parentFields != null)
        {
            return;
        }

        Field modiferField = Field.class.getDeclaredField("modifiers");
        modiferField.setAccessible(true);

        List<Field> filteredFields = new ArrayList<>();

        for (Field field : TexturedGlyph.class.getDeclaredFields())
        {
            int modifier = modiferField.getInt(field);

            if ((modifier & Modifier.STATIC) == Modifier.STATIC)
            {
                continue;
            }

            if ((modifier & Modifier.FINAL) == Modifier.FINAL)
            {
                modiferField.set(field, modifier & ~Modifier.FINAL);
            }

            field.setAccessible(true);
            filteredFields.add(field);
        }

        parentFields = filteredFields.toArray(new Field[]{});
    }
}

{'fraction_non_alphanumeric': 0.09196702763859706, 'fraction_numerical': 0.059641183125909165, 'mean_word_length': 2.020009760858956, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '535561', 'n_tokens_mistral': 2138, 'n_tokens_neox': 1874, 'n_words': 370}