構造物として保存する blocks.saveStructure
ひとことで言うと
指定した範囲の建物を、名前を付けて「構造物」として保存するブロックです。あとで別の場所に読み込めます。
ブロックとコード
構造物を保存する 名前"my structure"範囲の始まり~0 ~0 ~0範囲の終わり~0 ~0 ~0エンティティを含む○ブロックを含む○保存先○
ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。
blocks.saveStructure("my structure", pos(0, 0, 0), pos(0, 0, 0))blocks.save_structure("my structure", pos(0, 0, 0), pos(0, 0, 0))引数(ひきすう)
引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。
| 名前 | 選べる値 | 意味 |
|---|---|---|
| name | 文字列 | |
| from | 座標 | |
| to | 座標 | |
| includeEntities | 真偽値(true / false) | |
| saveMode | StructureSaveMode | |
| includeBlocks | 真偽値(true / false) |
使用例
Build a fenced corral that surrounds the player. Fill the corral with some horses. Save the horse corral as a structure so you can load it somewhere in the world later.
JavaScript
player.onChat("corral", function () {
blocks.fill(
SPRUCE_FENCE,
pos(-20, 0, -20),
pos(20, 0, 20),
FillOperation.Outline
)
for (let index = 0; index < 10; index++) {
mobs.spawn(HORSE, randpos(
pos(-19, 0, -19),
pos(19, 0, 19)
))
}
blocks.saveStructure(
"horse corral",
pos(-20, 0, -20),
pos(20, 0, 20)
)
})Python
def on_on_chat():
blocks.fill(SPRUCE_FENCE,
pos(-20, 0, -20),
pos(20, 0, 20),
FillOperation.OUTLINE)
for index in range(10):
mobs.spawn(HORSE, randpos(pos(-19, 0, -19), pos(19, 0, 19)))
blocks.save_structure("horse corral", pos(-20, 0, -20), pos(20, 0, 20))
player.on_chat("corral", on_on_chat)