Home›Java›Mods›Milk Bar
Milk Bar
ModsJava

Milk Bar

Java mod listed for Minecraft 26.x. Downloads from the MC Java Mods app on Android.

by Zurret · on Modrinth

A configurable challenge mechanic where players must drink milk to keep their survival bar from reaching zero.

⬇ Download on Modrinth

Milk Bar

MilkBarScreenshot

Milk Bar is a server-side Fabric mod for Minecraft 26.2. It adds a configurable survival challenge: every player has a private milk bar that drains while they are online. Drinking milk restores the bar. When it reaches zero, the player dies.

The mod is designed for both singleplayer and multiplayer. All challenge state is server-authoritative and stored per player using Fabric's persistent Data Attachment API.

Rules

A player receives the configured number of starter milk buckets only when their challenge state is initialized for the first time. The starter reward is never granted again because of death, respawn, reconnects, dimension changes, or server restarts.

The milk bar drains only while the player is alive and online. Offline time does not drain the bar.

When the bar reaches zero, the player is killed immediately. On every respawn, regardless of the cause of death, the milk bar is reset to its configured maximum. No additional starter milk is granted.

The boss bar is private to each player. One player's value is never sent to another player's boss bar.

Normal Minecraft milk consumption remains intact. A milk bucket restores the configured amount when its drinking action completes. If the bar is already full and consumeMilkWhenFull is enabled, the bucket is still consumed according to vanilla behavior but the challenge value cannot exceed the maximum.

If starter milk does not fully fit in the inventory, the remainder is dropped at the player's position instead of being silently lost.

Commands

All commands require permission level 2 or higher.

set clamps the value to the configured maximum. refill sets the value directly to the configured maximum. reload reloads config/milkbar.json and refreshes active boss bars without restarting the server.

Configuration

The file is created at config/milkbar.json.

{
  "enabled": true,
  "maxValue": 100,
  "drainAmount": 1,
  "drainIntervalTicks": 20,
  "milkRestoreAmount": 100,
  "starterMilkBuckets": 1,
  "giveStarterMilk": true,
  "consumeMilkWhenFull": true,
  "bossBarVisible": true,
  "bossBarTitle": "Milk: %value% / %max%",
  "bossBarColor": "GREEN",
  "bossBarOverlay": "PROGRESS",
  "bossBarDarkenScreen": false,
  "bossBarPlayMusic": false,
  "bossBarCreateFog": false
}

maxValue is the maximum bar value and accepts values from 1 to 1,000,000.

drainAmount is removed every drainIntervalTicks. drainIntervalTicks uses server ticks; 20 ticks is approximately one second.

milkRestoreAmount controls how much one milk bucket restores. Restoration is capped at maxValue.

starterMilkBuckets controls the one-time starter reward. giveStarterMilk disables that reward without disabling the challenge itself.

consumeMilkWhenFull controls whether a full bar still allows normal milk consumption. The current implementation does not cancel vanilla item use; when this option is false, the challenge does not restore while already full, but vanilla milk consumption is still performed.

bossBarTitle supports %value% and %max% placeholders.

bossBarColor supports the vanilla boss bar colors available in the target Minecraft version. bossBarOverlay supports the vanilla progress and notched overlays.

Boss bar visual effects are controlled by bossBarDarkenScreen, bossBarPlayMusic, and bossBarCreateFog.

Invalid numeric values are clamped to safe ranges. Invalid boss bar color and overlay values fall back to GREEN and PROGRESS.

Requirements

Build

./gradlew build

The compiled JAR is written to build/libs/.

Changelog

1.0.0

Architecture

PlayerMilkState is the persistent per-player domain state. The attachment is persistent across server restarts and copied to the respawned player instance. The controller deliberately resets only the current bar value during respawn.

MilkBarController owns gameplay state transitions, starter rewards, milk consumption detection, draining, death handling, respawn handling, and administration operations.

MilkBossBarManager owns private server boss bars and their lifecycle. Boss bars are explicitly removed and recreated across respawns so the new ServerPlayer instance always receives the correct bar.

MilkBarConfig validates configuration and supports in-place reloads so the controller and boss bar manager always reference the same configuration object.

The implementation does not use client-side code, mixins, custom networking, or a database.

License

Milk Bar is licensed under the MIT License.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

File checked by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more