> For the complete documentation index, see [llms.txt](https://enchantedmobs.superiormc.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enchantedmobs.superiormc.cn/format/match-item-format/logic-nbt.md).

# Logical and NBT Rules

Every rule on this page is a key inside a [MatchItemFormat](/format/match-item-format.md) section.

## Logical rules

***

## `any`

**Purpose:** Accepts an item when at least one nested alternative matches.

**Context:** Nested sections use the same MatchItemFormat rules.

### Fields

| Field | Default | Description                               |
| ----- | ------- | ----------------------------------------- |
| `any` | unset   | A direct rule section or numbered groups. |

### Direct-rule layout

```yaml
match-item:
  any:
    material:
      - diamond_sword
    contains-name:
      - Relic
```

When `any` does not contain a key named `1`, every directly nested rule is tested independently. The example matches a diamond sword **or** an item whose name contains `Relic`.

### Numbered-group layout

```yaml
match-item:
  any:
    1:
      material:
        - diamond_sword
      has-enchants:
        - sharpness
    2:
      items:
        - superior_sword
```

When `any` contains a key named `1`, each child is treated as a complete MatchItemFormat group:

* rules inside one numbered group use AND;
* numbered groups use OR.

### Behavior and limits

* An empty `any` section returns true.
* The numbered form is detected specifically by the presence of key `1`; use consecutive numeric keys beginning with `1`.
* In the direct layout, keys are alternatives rather than an AND group.
* Use the numbered layout whenever one alternative needs several rules.

***

## `not`

**Purpose:** Rejects an item when any nested rule matches.

**Context:** Nested keys use the same MatchItemFormat rules.

### Fields

| Field | Default | Description                             |
| ----- | ------- | --------------------------------------- |
| `not` | unset   | Rules whose matches should be rejected. |

### Example

```yaml
match-item:
  material-tag:
    - minecraft:swords
  not:
    contains-name:
      - Broken
    has-lore: false
```

### Behavior and limits

* Nested rules are tested as separate rejection alternatives.
* The example rejects the item if its name contains `Broken` **or** if it has no lore.
* `not` does not invert the AND result of all nested keys as one group.
* To reject a specific combination, place that combination in an `any` group outside the current matcher or restructure the surrounding configuration.
* An empty `not` section matches because no nested rule rejects the item.

## NBTAPI rules

The rules below are registered only when the plugin named `NBTAPI` is loaded during EnchantedMobs startup.

NBT paths use `;;` between compound names, the final key, operators, and values. Entries in each list use OR.

***

## `contains-nbt`

**Purpose:** Checks whether at least one NBT key exists.

**Context:** Requires NBTAPI.

### Fields

| Field          | Default | Description            |
| -------------- | ------- | ---------------------- |
| `contains-nbt` | unset   | NBT key paths to test. |

### Example

```yaml
match-item:
  contains-nbt:
    - CustomModelData
    - PublicBukkitValues;;myplugin:bound
```

### Behavior and limits

* A single segment checks a root key.
* Multiple segments traverse compounds and use the final segment as the required key.
* The value and NBT type are not checked.
* One existing key is sufficient.
* Missing compounds or keys do not match.

***

## `nbt-string`

**Purpose:** Matches an NBT string value exactly.

**Context:** Requires NBTAPI and an NBT string tag at the selected path.

### Fields

| Field        | Default | Description                                                         |
| ------------ | ------- | ------------------------------------------------------------------- |
| `nbt-string` | unset   | Entries in `path;;key;;value` form, or `key;;value` for a root key. |

### Example

```yaml
match-item:
  nbt-string:
    - owner;;Ming
    - PublicBukkitValues;;myplugin:class;;warrior
```

### Behavior and limits

* Root syntax is `key;;expected-value`.
* Nested syntax is `compound[;;compound...];;key;;expected-value`.
* The tag must be NBT string type.
* String comparison is exact and case-sensitive.
* The delimiter cannot be escaped inside a compound, key, or expected value.

***

## `nbt-byte`

**Purpose:** Compares an NBT byte value.

**Context:** Requires NBTAPI and an NBT byte tag.

### Fields

| Field      | Default | Description                                                                      |
| ---------- | ------- | -------------------------------------------------------------------------------- |
| `nbt-byte` | unset   | Entries in `path;;key;;operator;;value` form, or `key;;operator;;value` at root. |

### Example

```yaml
match-item:
  nbt-byte:
    - Unbreakable;;==;;1
    - data;;enabled;;>=;;1
```

### Behavior and limits

* Supported operators are `>=`, `>`, `<=`, `<`, and `==`.
* The expected value must fit Java's byte range.
* Invalid operators or numbers do not match; malformed numeric values may also produce a configuration-time/runtime parsing error when evaluated.
* Comparison uses the actual NBT byte value, not a boolean conversion.

***

## `nbt-int`

**Purpose:** Compares an NBT integer value.

**Context:** Requires NBTAPI and an NBT integer tag.

### Fields

| Field     | Default | Description                                                                      |
| --------- | ------- | -------------------------------------------------------------------------------- |
| `nbt-int` | unset   | Entries in `path;;key;;operator;;value` form, or `key;;operator;;value` at root. |

### Example

```yaml
match-item:
  nbt-int:
    - CustomModelData;;>=;;1000
    - stats;;kills;;>;;25
```

### Behavior and limits

* Supported operators are `>=`, `>`, `<=`, `<`, and `==`.
* The tag must be NBT integer type; byte, long, and double tags do not match.
* Nested compounds may be chained with additional `;;` segments.
* Entries use OR.

***

## `nbt-double`

**Purpose:** Compares an NBT double value.

**Context:** Requires NBTAPI and an NBT double tag.

### Fields

| Field        | Default | Description                                                                      |
| ------------ | ------- | -------------------------------------------------------------------------------- |
| `nbt-double` | unset   | Entries in `path;;key;;operator;;value` form, or `key;;operator;;value` at root. |

### Example

```yaml
match-item:
  nbt-double:
    - quality;;>=;;0.75
    - stats;;critical_chance;;>;;0.2
```

### Behavior and limits

* Supported operators are `>=`, `>`, `<=`, `<`, and `==`.
* `==` uses Java double equality; it does not apply an epsilon tolerance.
* Integer or float NBT tags do not match an NBT double rule.
* Invalid paths, types, operators, or values do not produce a match.
