エージェントにインタラクトさせる agent.interact

エージェント公式データ取得日:2026年11月13日動作確認待ち

ひとことで言うと

(右クリックしたように)操作する。

ブロックとコード

ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。

引数(ひきすう)

引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。

名前選べる値意味
direction方向アイテムを置く方向。たとえば:SixDirection.Back

使用例

Make two chat commands. One has the agent teleport to the player and then place a dark oak door from an inventory slot. The other chat command has the agent open and walk through the door.

JavaScript

player.onChat("placedoor", function () {
    agent.teleportToPlayer()
    agent.setItem(DARK_OAK_DOOR, 1, 1)
    agent.setSlot(1)
    agent.place(FORWARD)
})
player.onChat("opendoor", function () {
    agent.interact(FORWARD)
    agent.move(FORWARD, 2)
})

Python

def on_on_chat():
    agent.teleport_to_player()
    agent.set_item(DARK_OAK_DOOR, 1, 1)
    agent.set_slot(1)
    agent.place(FORWARD)
player.on_chat("placedoor", on_on_chat)

def on_on_chat2():
    agent.interact(FORWARD)
    agent.move(FORWARD, 2)
player.on_chat("opendoor", on_on_chat2)
執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにMakeCodeを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む