Consumable Items - MarkusBordihn/BOs-Easy-NPC GitHub Wiki
Consumable Items
Consumable items are reusable Easy NPC items for quests, checks, trades, dialog logic, and small server workflows. They are intentionally simple: the same base item can become a named key, coin, token, voucher, or quest marker by adding custom item data.
Available Items
The current consumable items are:
easy_npc:npc_coin- coin or currency itemeasy_npc:npc_key- key or access itemeasy_npc:npc_red_token- red token or marker item
Their textures are stored under:
assets/easy_npc/textures/item/consumable/
Resource packs can replace these PNG files without changing presets, dialogs, or trades.
Custom Item Data
Consumable items support three custom data fields:
Name- custom visible item nameColor- optional Minecraft text color for the custom nameDescription- custom tooltip line
Minecraft 1.20.1
Minecraft 1.20.1 uses legacy item NBT directly after the item id:
/give @p easy_npc:npc_coin{Name:"Welcome Coin",Color:"gold",Description:"A small token for your first visit today."} 1
Minecraft 1.21.1 and newer
Minecraft 1.21.1 and newer use item components. For Easy NPC consumable item metadata, use the Easy NPC component namespace:
/give @p easy_npc:npc_coin[easy_npc:custom_data={Name:"Welcome Coin",Color:"gold",Description:"A small token for your first visit today."}] 1
Do not use minecraft:custom_data for new Easy NPC consumable item metadata in 1.21.1 and newer.
Easy NPC still reads old vanilla custom data for compatibility, but new commands should use
easy_npc:custom_data.
If no custom data is present, the item uses the normal translated item name and tooltip from the language files.
Name Colors
Color uses Minecraft chat formatting color names. Useful examples:
goldyellowredgreenaquabluelight_purplewhitegray
Formatting values such as bold or italic are ignored here; only actual colors are applied.
Conditions
Consumable items are useful with item conditions. Use CustomData when the check should match a
specific custom version of the item.
Example condition data:
{
Count:1,
CustomDataComponent:"easy_npc:custom_data",
CustomData:'Name:"Welcome Coin",Color:"gold"',
Name:"easy_npc:npc_coin",
Type:"HAS_ITEM_IN_INVENTORY"
}
CustomDataComponent is optional. When it is empty, Easy NPC checks known custom data components
such as easy_npc:custom_data and legacy minecraft:custom_data. When it is set, only that exact
component is checked.
CustomData accepts both full compound SNBT ({Name:"Welcome Coin",Color:"gold"}) and the shorter
condition form without outer braces (Name:"Welcome Coin",Color:"gold").
The custom data check is a subset match. This means the condition above still matches an item that
also has a Description tag.
Trading
Consumable items can be used directly in custom trade data.
Minecraft 1.20.1
Legacy custom trade data uses Count and tag:
buy:{Count:1b,id:"easy_npc:npc_coin",tag:{Name:"Welcome Coin",Color:"gold"}}
sell:{Count:1b,id:"easy_npc:npc_key",tag:{Name:"Ledger Key",Color:"yellow",Description:"A key for a small surprise chest."}}
Minecraft 1.21.1 and newer
Modern custom trade data uses count and components:
buy:{count:1,id:"easy_npc:npc_coin",components:{"easy_npc:custom_data":{Name:"Welcome Coin",Color:"gold"}}}
sell:{count:1,id:"easy_npc:npc_key",components:{"easy_npc:custom_data":{Name:"Ledger Key",Color:"yellow",Description:"A key for a small surprise chest."}}}
Older trade data that still contains tag or minecraft:custom_data is migrated when Easy NPC
loads it, but new presets should use easy_npc:custom_data.
This makes it possible to create NPC-specific currencies, daily rewards, quest keys, and unlock tokens without adding a new item class for every variation.
Preset Example
The default preset villager/welcome_coin_trader.npc.snbt shows a complete consumable-item
workflow:
- gives a daily
Welcome Coin - uses a dialog condition to react to the coin
- trades the coin for custom tokens and keys
- trades multiple keys for a small surprise chest