1

I am trying to make a survival datapack that would require you to drink water. Is it possible to add an element to the HUD to indicate how much water you need based on a scoreboard value? I did some research and it might be possible with Spigot, and I would like to stay with vanilla commands but I would be OK with using Spigot/Fabric. I don't really want to use Forge because of optimization/performance reasons.

1 Answer 1

0

Preface: I do not understand how to solve this problem, but I know of a video where someone can describe it in detail.


You can use custom fonts, as shown in this video:

I'll summarize it here:

The game recognizes Unicode characters, such as this delete character:

tellraw @s {"text":"\u0010"}

However, The game only recognizes a certain amount of Unicode characters. So, you can use a resourcepack to replace the unused characters with an image file of your own. These unused characters range from \uE000 to \uFFFF, in hexadecimal.

Here is an example of a font file, located in assets > minecraft > font > default.json:

{
    "providers": [
        {
            "type": "bitmap",
            "file": "minecraft:custom/icon.png",
            "ascent": 2,
            "height": 27,
            "chars": ["\uE000"]
        },
        {
            "type": "bitmap",
            "file": "minecraft:custom/icon_half.png",
            "ascent": 2,
            "height": 27,
            "chars": ["\uE001"]
        },
        {
            "type": "bitmap",
            "file": "minecraft:custom/icon_off.png",
            "ascent": 2,
            "height": 27,
            "chars": ["\uE002"]
        }
    ]
}

By displaying these characters in the actionbar, it starts to resemble a custom bar. To position the character properly (such as above the hearts), you have to modify the "ascent" and "height" values of the character such that they are displaced to the area of the screen you want. This can also change the size of the character.

To help position the characters properly, you'll probably need a negative space font character: https://github.com/AmberWat/NegativeSpaceFont


Sorry I didn't explain too clearly, this is not my area of expertise. If anyone knows better than I, please edit! I hope this helped guide your efforts.

1
  • Thanks much! I would have never thought to use a font. Commented Jul 15, 2022 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.