BetterHud

repository·master·Indexed 42 days ago

https://github.com/toxicity188/betterhud

A multiplatform server-side HUD implementation for Minecraft supporting Bukkit (1.21 through 26.1.x), Velocity (3.3 through 3.5), and Fabric (26.1.x). It enables custom UI elements, animations, and images via auto-generated resource packs without requiring client-side mods. Features include a ShaderManager for custom shader logic, a HudPlaceholder API for dynamic data, and integrations with Skript and MythicMobs.

Tokens
6K
Snippets
25
Records
33
Agent score
52%

What's inside BetterHud

  1. Overview of BetterHud features

    master

    BetterHud is a multiplatform server-side HUD implementation for Minecraft that allows you to create custom HUDs without requiring players to install any mods.

    Key features include:

    • No Mod Required: HUDs are delivered via an automatic resource pack generation system.
    • High Performance: Operates completely asynchronously to prevent server TPS degradation.
    • Advanced Visuals: Supports TTF (TrueType Font), animations, and GIFs.
    • Customization: Includes an enhanced popup system, ability to relocate the hotbar, and options to remove XP text.
    • Non-Intrusive: While it utilizes boss bars for rendering, it does not interfere with the vanilla boss bar if you are already using one.
  2. Overview of BetterHud

    master

    BetterHud is a multiplatform, server-side HUD implementation for Minecraft. It allows servers to display custom UI elements to players without requiring client-side mods (though it supports auto-generating resource packs).

    Key features include:

    • Auto-generated resource packs: Simplifies deployment of custom assets.
    • Visual Elements: Supports displaying images (including PNG sequences), text, and player heads.
    • Animations: Supports animated HUD elements.
  3. Add dependencies for BetterHud API

    master

    BetterHud publishes its APIs to Maven Central. To use the API in your project, add the following dependencies to your build.gradle file, replacing VERSION with the appropriate version number.

    • BetterHud-standard-api: For the core standard API.
    • BetterHud-bukkit-api: For platform-specific Bukkit functionality.
    dependencies {
        compileOnly("io.github.toxicity188:BetterHud-standard-api:VERSION") //Standard API
        compileOnly("io.github.toxicity188:BetterHud-bukkit-api:VERSION") //Platform API
    }
  4. Generate and customize your own language file

    master

    BetterHud supports custom language files (e.g., en_US.json) located in the BetterHud/lang/ directory. To create a translation file for your server:

    1. Join your server.
    2. Run the command /hud gen to generate the base language file.
    3. Edit the resulting file at BetterHud/lang/your_language.json to add your translations.
    4. (Optional) You can contribute your language file by uploading it to the project's Discord or submitting a Pull Request on GitHub.
    /hud gen
  5. Update BetterHud shaders for 1.21.6 compatibility

    master

    To support Minecraft client version 1.21.6, the resource pack structure has changed significantly. If you are updating to a version that includes 1.21.6 support, you must perform the following steps to avoid conflicts with the old shader structure:

    1. Delete the BetterHud/shaders directory.
    2. Execute the /reload command in-game to generate and use the new shader files.
  6. Supported Platforms and Dependencies

    master

    BetterHud is designed to work across multiple Minecraft server environments. Depending on your platform, you may need specific dependencies:

    • Bukkit (including Folia): Supports versions 1.21 through 26.1.x. No additional dependencies required.
    • Velocity: Supports versions 3.3 through 3.5. No additional dependencies required.
    • Fabric Server: Supports version 26.1.x. Requires Fabric API.
  7. Configure image children and mapping

    master

    In version 1.10, the image type supports a children setting. This allows you to define a hierarchy of images that can be swapped based on specific conditions using a children-mapper.

    • children: A list of image identifiers to be used as children.
    • children-mapper: Defines logic to replace the parent image with a specific child image when a condition is met. Conditions use first (placeholder), second (value), and operation (e.g., <).
    • Use the wildcard * in the children field to include all available images.
    • Use the follow key to make the image visibility depend on a placeholder (e.g., skript_variable:your_value).
    children_full:
      type: single
      file: "children/full.png"
      setting:
        children:
          - children_half
          - children_container
        children-mapper:
          children_container:
            1:
              first: health_percentage
              second: 0.33
              operation: "<"
          children_half:
            1:
              first: health_percentage
              second: 0.66
              operation: "<"
  8. Configure image animation types

    master

    When using a sequence type for images, you can specify an animation-type within the setting block. This allows you to control how the sequence of frames is played.

    sequence_image:
      type: sequence
      files:
        - "sequence/frame_0.png:2"
        - "sequence/frame_1.png:2"
        - "sequence/frame_2.png:2"
        - "sequence/frame_3.png:2"
        - "sequence/frame_4.png:2"
        - "sequence/frame_5.png:2"
        - "sequence/frame_6.png:2"
        - "sequence/frame_7.png:2"
      setting:
        animation-type: play_once
  9. Configure render scale and static-scale

    master

    When defining render-scale for elements like heads, you can use the static-scale option. Setting static-scale: true ensures the scale remains constant.

    test_head:
      heads:
        1:
          name: test_head
          align: center
          type: fancy
          y: 64
          x: 64
          render-scale:
            x: 3.0
            y: 3.0
            static-scale: true
  10. Format placeholders in text elements

    master

    Text elements support advanced placeholder manipulation via placeholder-option and placeholder-string-format:

    • placeholder-option: Allows mathematical evaluation or joining of values. Use evaluate for expressions (e.g., t * 100) and join to combine strings.
    • placeholder-string-format: Allows formatting of numbers, such as setting decimal patterns (e.g., number: "#,###").
    test_text:
      texts:
        1:
          name: unifont
          pattern: |
            [name]
            [health_percentage]%
          placeholder-option:
            evaluate: t * 100
            join: " "
          placeholder-string-format:
            number: "#,###"
          background: test
          align: center
          line-align: center
          scale: 0.5
          line: 5
          split-width: 300
          y: 32
  11. Configure HUD outline colors using ARGB

    master

    Starting with version 1.13.0, HUD outlines support ARGB color formatting. The format follows AARRGGBB, where the first two characters represent the Alpha channel (00 for transparent, FF for fully opaque).

    Example: FF0026FF represents a blue color with an alpha value of 255.

    #true = 0xFF000000, false = 0
    outline: FF0026FF #blue with alpha 255