The Best Resource for Minecraft
The Best Resource for Minecraft

Mga bossbar at title: persistent state, timings, at ang value/max split

Mga bossbar at title: persistent state, timings, at ang value/max split

Nananatili ang bossbar pagkatapos ng restart ngunit hindi ang title. Narito ang create-then-modify pattern, ang fade timings na baligtad na naitatakda ng iba, at kung paano magpagana ng progress bar.

Pareho silang nagpapakita ng teksto sa screen at doon nagtatapos ang pagkakatulad. Ang mga title ay fire-and-forget; ang mga bossbar ay mga persistent object na kailangan mong pamahalaan.

Stateful ang mga bossbar

/bossbar add my:timer {"text":"Time left"}
/bossbar set my:timer players @a
/bossbar set my:timer max 600
/bossbar set my:timer value 600
/bossbar set my:timer color red
/bossbar set my:timer style notched_10

Isang id, tapos mga command na nagbabago rito. Mga puntong madalas pagkamalian:

  • Hindi nakikita ang bar hanggang sa magkaroon ito ng mga manlalaro. Paggawa ng isa at hindi kailanman pagpapatakbo ng

set ... players produces nothing, with no error.

  • Nananatili ito sa world save. Nandoon pa rin ang bar na ginawa para sa isang minigame sa susunod na

sesyon. /bossbar remove when finished, or they accumulate.

  • value and max are separate, at ipinapakita ng bar ang value / max. Setting only

value on a bar whose max is still 100 gives nonsense fill.

Mga Kulay: pink white red orange yellow green blue purple. Styles: progress notched_6 notched_10 notched_12 notched_20.

Pagpapagana ng countdown

/bossbar set my:timer value 599

isang beses bawat segundo mula sa isang repeating function ang buong mekanismo. Walang built-in na timer. Kapaki-pakinabang din ang pagbasa nito pabalik:

/execute store result score @s Left run bossbar get my:timer value

bossbar get supports value, max, players and visible, which makes a bossbar a workable global variable when you want the player to see it.

Pansamantala lang ang mga title

/title @a times 10 70 20
/title @a subtitle {"text":"Get ready"}
/title @a title {"text":"Round 2"}

Tatlong bagay sa ganoong pagkakasunod-sunod, at mahalaga ang pagkakasunod-sunod:

  1. times first. Walang epekto sa naipakita nang title ang pagtatakda nito pagkatapos ng title.
  2. subtitle before title. Walang ipinapakita ang subtitle lamang; ang pagpapadala ng title

ang nagti-trigger para lumabas ang pares. Kapag binaligtad, lalabas ang una nang walang subtitle.

times is fadeIn stay fadeOut sa mga tick — 20 ticks bawat segundo. 10 70 20 is half a second in, three and a half held, one out. People set 1 1 1 and wonder why nothing appears: three ticks total is a flash.

hiwalay ang actionbar

/title @a actionbar {"text":"Saved"}

Ang linya sa itaas ng hotbar. Hindi nito pinapansin ang times entirely — it shows for a fixed couple of seconds and fades. Re-sending it every tick keeps it up permanently, which is the standard way to run a custom HUD.

Pag-clear

/title @a clear removes what is showing; /title @a reset also restores default timings. For bossbars, /bossbar set my:timer visible false hides without destroying state.

Gumawa ng bossbar, title, at iba pang control at debug command mula sa isang form sa Advanced Command Builder — Control & Debug.

Subukan ang tool: Advanced Command Builder — Control & Debug →