-
Notifications
You must be signed in to change notification settings - Fork 0
Creating A Status Bar
Sygikal edited this page Jun 12, 2025
·
15 revisions
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.
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:LEFTorRIGHTfor which side of the hotbar its on. -
direction:L2RorR2Lfor 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.
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 theStatusBar's texture. -
StatusBarRenderer.Position positon:LEFTorRIGHTfor which side of the hotbar its on (overwritten by whatever's in the json file) -
StatusBarRenderer.Direction direction:L2RorR2Lfor 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.
-
xandyare determined by the api and will update dynamically. -
logicis theStatusBarLogicand provides whatevervalueandmaxValuewere 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.
- Optional. Returns the height of the status bar. Default
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 byPlayerEntity(ex.(playerEntity) -> playerEntity.getMaxHealth()) -
StatusBarLogic.RunningFloat value: Value of the bar as provided byPlayerEntity(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.
- Optional. Ddetermines if the status bar is visible. Default