メインコンテンツまでスキップ

set_item

概要

set_item は、プレイヤーのインベントリにアイテムを設定する ScriptEvent です。
spawn_item と似ていますが、こちらは直接インベントリに追加します。

構文

/scriptevent capi:set_item <パラメータ>

パラメータ

パラメータはJSON形式またはESON形式で指定できます:

{id=アイテムID,name=アイテム名,amount=数量,slot=スロット番号,lore=[説明文1,説明文2],enchants=[{name=エンチャント名,level=レベル}],can_place_on=[ブロックID],can_destroy=[ブロックID],lock=ロックモード,keep_on_death=true}
パラメータ説明必須
idアイテムID
nameアイテムの表示名×
amount数量×
slotスロット番号(0-35)×
lore説明文の配列×
enchantsエンチャントの配列×
can_place_on設置可能なブロック×
can_destroy破壊可能なブロック×
lockアイテムロックモード×
keep_on_death死亡時に保持×

使用例

シンプルなアイテム付与

ダイヤモンドをインベントリに追加します。

/execute as @a run scriptevent capi:set_item {id=diamond}

数量を指定して付与

64個の土ブロックを追加します。

/execute as @a run scriptevent capi:set_item {id=dirt,amount=64}

特定のスロットに設定

スロット0にダイヤモンドの剣を設定します。

/execute as @a run scriptevent capi:set_item {id=diamond_sword,slot=0}

名前付きアイテム

カスタム名を付けたアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=diamond_sword,name=§6伝説の剣}

説明文付きアイテム

説明文を付けたアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=diamond_sword,name=§6勇者の剣,lore=["§7伝説の武器","§7攻撃力 +10"]}

エンチャント付きアイテム

エンチャントを付けたダイヤモンドの剣を付与します。

/execute as @a run scriptevent capi:set_item {id=diamond_sword,enchants=[{name=sharpness,level=5},{name=fire_aspect,level=2}]}

死亡時に保持するアイテム

死亡時に失わないアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=totem_of_undying,keep_on_death=true,slot=0}

完全にカスタマイズされたアイテム

全ての設定を行ったアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=diamond_sword,name=§c§l最強の剣,amount=1,slot=0,lore=["§7伝説の武器","§7攻撃力 +100","§7クリティカル率 +50%"],enchants=[{name=sharpness,level=10},{name=fire_aspect,level=5},{name=looting,level=3}],keep_on_death=true}

マクロを使用したアイテム

プレイヤー名を含む名前のアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=diamond,name=<!name>のダイヤモンド}

特定のブロックにのみ設置可能

特定のブロックにのみ設置できるアイテムを付与します。

/execute as @a run scriptevent capi:set_item {id=stone,can_place_on=["dirt","grass_block"]}

スロット番号の参考

スロット場所
0-8ホットバー
9-35メインインベントリ

注意事項

  • プレイヤーのみが実行できます
  • id パラメータは必須です
  • amount のデフォルト値は 1 です
  • slot を指定しない場合(-1)、空いているスロットに追加されます
  • slot を指定した場合、そのスロットの既存アイテムは上書きされます
  • 無効なアイテムIDを指定するとエラーが発生します

関連項目