0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

スコアボードの「表示」を操作する

Last updated at Posted at 2025-03-02

scoreboardをsidebarに表示する時の見た目を変更します。
1.20.3でこの機能が追加されました。海外サーバーなどでよくあるやつも、Vanillaで再現できます。

↓もはや原型をとどめない
image.png

タイトル表示を変更する

scoreboardの一番上の表示名は、RawJSONで直接表記できます。
[] でくくれば複数表記も可能です。

scoreboard objectives add test dummy [{"text": "Red","color": "red"},{"text": "Green","color": "#255c25"}]

一度設定した後も、scoreboard objectives modify <object> displayname <RawJSON> で変更可能です。

スコアホルダーの表示を変更する

ただスコアを設定するだけではRawJSONテキスト形式を使うことも、スペースを入れることもできません。

色を変更する

§ を用いた表記で用意されている色・太字・斜体など設定できます。
スペースが入った名前は設定できません。また、マインクラフト上では § は入力できないので datapack などから呼び出す必要があります。

scoreboard players set §cRedTeam test 1

RawJSONでスコア名を変更する

すでにスコアが存在するスコアホルダーの表示を変更します。

scoreboard players set _ test 1

これに対し、scoreboard players display name <scoreholder> <objective> <RawJSON> でRawJSONを用いたテキスト表記で記述できます。

scoreboard players display name _ test {"text": "This is test score."}

ただし、tellrawtitle とは異なり、intersection score selector などの参照は一切行われません。そのため、動的に変化するスコアを表示したい場合、マクロを用いる必要があります。

例えば、「Test score: 」のように表示したい場合、スコアをstorageにcompound型で格納した後にマクロで実行する。

tutorial\function\setscore
execute store result storage test: set.score int 1 run scoreboard players get _ test2
function tutorial:macro with storage test: set
tutorial\function\macro
$scoreboard players display name _ test {"text": "Test score: $(score)"}

なお、参照先のスコアが変更しても表示名は動的に変化しないので、都度表示名を変更するfunctionを実行する必要がある。また、表示名を変更しているだけなので、数値を変更したいときはスコアホルダーの名前で変更する(この例だと _ に対して数値変更を行う)。

補足:compound型について

マクロで参照されるのは compound型 だが、説明が少ないので補足説明です。 自分がわからなかっただけ

数値や値を直接参照することができないのがマクロです。
整数値を示す int 、浮動小数点を示す float などがありますが、それとは少し異なったデータの形です。

compound型は、nbtのようなものです。
data get entity @s Health を実行すると 20.0f のように Health: 20.0f というような関係のデータのことを指します。

そのため、storageに格納するときも data modify test: aaa.bbb set value ~ という指定にすると、{aaa: {bbb: ~}} というcompound型の格納になり、これをマクロで使用することができます。

また、マクロ一つの文章内で複数個の指定ができます。
function ~ with entity @s とし、 $tellraw @a {"text": "$(Health), $(Pos)"} と記述すればその情報を同時に表示できます。

スコアホルダーの数値の表記を変更する

基本赤文字で表示される数値部分も自由に変更できます。

構文:
scoreboard players display numberformat <scoreholder> <objective> style/fixed/blank

  • style
    text なしで color italic などの装飾部分のみを記述して「数字」の部分の表示を変更する。デフォルト値は {"color": "red"}
scoreboard players display numberformat _ test style {"italic": true,"bold": true}
  • fixed
    styletext が加わったもの。こちらでのみ好きな文字を表示できる。
scoreboard players display numberformat _ test fixed {"text": "Is it true?","color": "#66a5b8"}
  • blank
    スコアや文字を一切表示しません。
scoreboard players display numberformat _ test blank

おわりに

配布マップなどでもスコアボードの表示が変わるだけでも印象が変わるのでぜひいろいろ試してみてください!

参考:MINECRAFT WIKI / スコアボード
https://ja.minecraft.wiki/w/%E3%82%B9%E3%82%B3%E3%82%A2%E3%83%9C%E3%83%BC%E3%83%89

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?