π§ Logical and NBT Rules
This page documents MatchItemFormat composition and optional legacy NBT matching.
Rules on this page
noneanynotcontains-nbtnbt-stringnbt-bytenbt-intnbt-double
The NBT rules are registered only when NBTAPI is available while EnchantmentReform enables.
Default AND behavior
Every recognized rule at the same level must pass:
match-item:
material-tag:
- minecraft:swords
has-name: true
contains-name:
- LegendaryThe item must satisfy all three rule groups.
none
Forces a MatchItemFormat section to fail when enabled.
This is useful as an explicit disabled placeholder or a generated configuration value. It is clearer to remove an unused optional filter when possible.
any
Passes when at least one nested group matches.
Each child under any is a complete MatchItemFormat group. Rules inside one child still use AND.
Mixed provider and vanilla alternative
This passes for the provider item, or for a Netherite pickaxe with Efficiency.
not
Rejects a nested match.
The item must be damageable and must not have lore containing Disabled.
Reject several alternatives
Nested logic
The following expression means:
Keep nesting shallow when possible. Deep logic is harder to debug and can usually be replaced with reusable item IDs/tags.
Optional NBT rules
Modern Minecraft item data increasingly uses data components rather than legacy arbitrary NBT. The rules below exist for compatibility through NBTAPI and should not be the first choice for new configuration.
If NBTAPI is not loaded when EnchantmentReform registers match rules, these keys are unknown and therefore ignored. An ignored optional key can make a match broader than intended. Verify startup logs before relying on NBT rules.
contains-nbt
Checks whether the item contains a configured NBT structure or path/value set.
The exact serialization syntax follows the NBTAPI-backed matcher implementation. Start from a working bundled/provider example.
nbt-string
Checks a string NBT value.
Path and field names are case-sensitive where the underlying NBT is case-sensitive.
nbt-byte
Checks a byte value, commonly used for boolean-like flags.
Do not assume every boolean component is represented as a legacy byte on modern versions.
nbt-int
Checks an integer value.
Use an integer rule only when the stored tag type is actually integer. Numeric NBT types are not always automatically converted.
nbt-double
Checks a double value.
Exact floating-point comparison can be fragile. Prefer a stable integer tier or provider ID where possible.
NBT versus PDC and provider IDs
Prefer these identifiers in order:
registered custom-item provider ID;
namespaced enchantment key;
stable material/tag and component metadata;
plugin-owned PersistentDataContainer/component rule where supported;
legacy NBT matching only when necessary.
Provider plugins may rewrite their internal NBT between versions while keeping the public item ID stable.
Debugging logic
Test each nested group as the entire
match-itemsection.Confirm every rule key is registered.
Replace optional NBT checks with a material/provider-ID check temporarily.
Verify the actual NBT type, path, and value with a trusted inspection tool.
Add
notonly after the positive rule works.Log or display the exact item used by the trigger; delayed/equipment events may provide a different item than expected.
Common mistakes
expecting top-level rules to use OR;
placing several individual rule keys under
anywithout grouping them correctly;accidentally negating a broader group than intended;
relying on an NBT rule when NBTAPI was not registered;
comparing an integer tag with
nbt-doubleor vice versa;matching provider-private NBT instead of the public item ID;
assuming unknown keys make the match fail.
See Basic and Metadata Rules and Enchantment and ItemFormat Rules.
Last updated