是否可以將組件/條添加到 HUD Minecraft Java 1.19.x
我正在嘗試製作一個需要你喝水的生存數據包。是否可以在 HUD 中添加一個元素,以根據記分牌值指示您需要多少水?我做了一些研究,可能使用 Spigot,我想繼續使用 vanilla 命令,但我可以使用 Spigot/Fabric。由於優化/性能原因,我真的不想使用 Forge。
前言:我不明白如何解決這個問題,但我知道有人可以詳細描述它的影片。
您可以使用自定義字型,如本影片所示:
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.