Skip to content

Creating A Status Bar

Sygikal edited this page Jun 12, 2025 · 15 revisions

Overview

Status Bars come in 3 parts:

  • The json for registration
  • The Renderer
  • The Logic

The json is your typical datapack json file whilst the renderer and logic must be registered with java through the API.

JSON

The status bar must me located under the status_bar folder. This is an example and will render the bar between the armor and health bars and replace the hunger one.

data/custom_hotbar_datapack/status_bar/custom.json

{
  "before": [
    "minecraft:armor"
  ],
  "after": [
    "minecraft:health"
  ],
  "replace": "minecraft:hunger",
  "texture": "custom_hotbar_datapack:textures/gui/custom_hunger.png",
  "position": "LEFT",
  "direction" : "L2R",
  "renderer": "customhunger:hunger_renderer",
  "logic": "customhunger:hunger_logic"
}
  • before: Array of status bars that it should render before.
  • after: Array of status bars that it should render after.
  • replace: Status bar it will replace:
  • texture: Probably not needed if your using a custom renderer, has to follow a certain format if your using default renderer.
  • position: LEFT or RIGHT for which side of the hotbar its on.
  • direction: L2R or R2L for which way it will fill up.
  • renderer: (Optional) The renderer to use, if not set it will use default simple one.
  • logic: (Optional) The logic for when the bar will be visible, and which values it will read (if using default renderer). If not set it will revert to default logic and always be visible and expect its values to be handled in rendering.

Renderer

This is a java class that extends StatusBarRenderer. It can be registered with HotbarAPI.registerStatusBarRenderer() When instantiating you need to specify:

  • Identifier id: How it will be referenced.
  • Identifier texture: Sets the StatusBar's texture.
  • StatusBarRenderer.Position positon: LEFT or RIGHT for which side of the hotbar its on (overwritten by whatever's in the json file)
  • StatusBarRenderer.Direction direction: L2R or R2L for which way it will fill up (overwritten by whatever's in the json file)

The methods you need to override are:

  • void render(MinecraftClient client, DrawContext context, PlayerEntity playerEntity, int x, int y, StatusBarLogic logic):
    • This is the actual rendering method.
    • x and y are determined by the api and will update dynamically.
    • logic is the StatusBarLogic and provides whatever value and maxValue were set. (Really not needed if your using custom rendering)
  • float getHeight(MinecraftClient client, PlayerEntity playerEntity):
    • Optional. Returns the height of the status bar. Default 10.

Logic

This is a java class that extends StatusBarLogic. It can be registered with HotbarAPI.registerStatusBarLogic() When instantiating you need to specify:

  • Identifier id: How it will be referenced.
  • StatusBarLogic.RunningFloat maxValue: Max value of the bar as provided by PlayerEntity (ex. (playerEntity) -> playerEntity.getMaxHealth())
  • StatusBarLogic.RunningFloat value: Value of the bar as provided by PlayerEntity (ex. (playerEntity) -> playerEntity.getHealth())

The methods you need to override are:

  • boolean isVisible(MinecraftClient client, PlayerEntity playerEntity):
    • Optional. Ddetermines if the status bar is visible. Default true.

Clone this wiki locally