# エンチャントを付ける（mobs.enchant）

> 指定されたターゲットに特定のエンチャントを適用します。

- カテゴリ：モブ（mobs）
- ブロック：手に持っているアイテムにエンチャントを付与する 対象@s エンチャントのID"infinity" エンチャントのレベル1
- URL：https://makecode.minecraft-okinawa.com/reference/mobs/enchant/
- 公式データ取得日：2026-11-13
- 動作確認：確認待ち

## JavaScript

```javascript
mobs.enchant(mobs.target(LOCAL_PLAYER), "infinity", 1)
```

## Python

```python
mobs.enchant(mobs.target(LOCAL_PLAYER), "infinity", 1)
```

## 引数

| 名前 | 値 | 意味 |
|---|---|---|
| target | ターゲットセレクター | どのプレイヤーがエンチャントを得るかを決定するターゲットセレクター |
| spell | 文字列 | エンチャントのコードネーム。たとえば：「infinity」 |
| level | 数値 | エンチャントの強さ。たとえば：1 |

## 使用例

### Enchant the tool that current player has so it lasts longer.

```javascript
mobs.enchant(mobs.target(LOCAL_PLAYER), "unbreaking", 3);
```

```python
mobs.enchant(mobs.target(LOCAL_PLAYER), "unbreaking", 3)
```

## 出典

- [MakeCode for Minecraft 公式リファレンス（mobs.enchant）](https://minecraft.makecode.com/reference/mobs/enchant)

執筆：鈴木孝昌（現役プロジェクトマネージャー／マイクラカップ指導者）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）