# Custom Items

## Identification

When players get a hold of an item, the item may not stay the same. A player could add or remove enchantments, rename the item, and most commonly, decrease the tool's durability. This means the tool is modified, and will now fail certain conditions.

Example:

{% code overflow="wrap" lineNumbers="true" %}

```python
on load:
  set {customItems::excalibur} to (1 of diamond sword)
  set (name of {customItems::excalibur}) to "&6Excalibur"
  enchant {customItems::excalibur} with sharpness 10

on right-click with diamond sword:
  if player's tool = {customItems::excalibur}:
    broadcast "%player's name% has Excalibur!"
    strike lightning effect at player's location
```

{% endcode %}

In this example, line 7 checks the player's tool against a variable. However, this variable is a snapshot of the original item, an Excalibur with no extra enchantments, a specific name, and most importantly, full durability. The `player's tool` expression on the other hand, is an instantaneous snapshot, getting the item the player is currently holding. Once a player uses their fancy new sword, it will inevitably lose durability, or they'll rename it, or enchant it. Then the item in their hand is not ***exactly*** the item in the variable.

{% hint style="success" %}
To always be able to identify an item in any scenario, add a custom NBT tag, and then check for that tag later.

See the [Setting NBT](#setting-nbt) and [Checking NBT](#checking-nbt) sections to learn how.
{% endhint %}

{% hint style="info" %}
The SkBee wiki also covers this topic quite nicely: <https://github.com/ShaneBeee/SkBee/wiki/Tricks-Item-Comparison>
{% endhint %}

***

## Item attributes

...

***

## Item abilitites

If you have been storing the item's uses in lore or a variable, you should consider switching to an NBT tag. While displaying the text "Remaining uses: 54" in an item's lore is a good way to display the remaining uses, it is not a good way to work with them. Since lore is just a string, you cannot get the remaining uses without first getting the lore, then removing the extra characters from the lore, and then parsing the lore as a number. An NBT tag is a much more direct and simple way to manage an item's custom properties.

As for variables, those take up precious space in the variables database, whereas NBT is hidden within the item. Variables are also tied to a player, not an item,,,


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://x8ight.gitbook.io/syntask/storage/nbt-tags/custom-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
