# ID System (Item & Block ids)

{% hint style="info" %}
It is recommended to use Blocks.Instance.GetId in the **Start** function of your ITask class, and store results in variables for the whole class to use. This is considered best practice for performance.
{% endhint %}

{% hint style="info" %}
You can find item id name's in such sites: <https://minecraftitemids.com/>, <https://www.minecraftinfo.com/idlist.htm>, <https://www.deadmap.com/idlist> ...
{% endhint %}

## Blocks

The simplest form of getting a numeric id for both legacy ids (1.8-1.12) and the flattened ids is to use the static Blocks.Instance global variable.

**Example usage:**

```csharp
var redstoneLampId = Blocks.Instance.GetId("minecraft:redstone_lamp").Value;
```

*Note how GetId() returns a ushort?, this means that in cases where the passed string, in this case "minecraft:resdstone\_lamp" is not a valid or a matching name, then null is returned.*

*This null mechanism is useful in casses where Minecraft uses different names for different versions, as in some cases you can do the following:*

```csharp
var someBlockId = Blocks.Instance.GetId("minecraft:some_block_1_8_name") ?? Blocks.Instance.GetId("minecraft:some_block_1_13_name");
```

### Block more utility

There are also more functions on Blocks.Instance that make it easier to work with ids. The notable ones are:

* **Blocks.Instance.GetIds -** get an array of ids for an array of inputs, example usage:

```csharp
var fallingBlocks = Blocks.Instance.GetIds("minecraft:sand", "minecraft:red_sand", "minecraft:gravel");
```

* ...

## Items

Item ids work in the exact same way as the Block system, except it uses \***Items\*.Instance.GetId, instead of \*Blocks\*.Instance.GetId!**

**Example usage:**

```csharp
var fishingRodId= Items.Instance.GetId("minecraft:fishing_rod").Value;
```

*Note how GetId() returns a ushort?, this means that in cases where the passed string, in this case "minecraft:fishing\_rod" is not a valid or a matching name, then null is returned.*

*This null mechanism is useful in casses where Minecraft uses different names for different versions, as in some cases you can do the following:*

```csharp
var someItemId = Items.Instance.GetId("minecraft:some_item_1_8_name") ?? Items.Instance.GetId("minecraft:some_item_1_13_name");
```

### Items more utility

There are also more functions on Items.Instance that make it easier to work with ids. The notable ones are:

* **Items.Instance.GetIds -** get an array of ids for an array of inputs, example usage:

```csharp
var food = Items.Instance.GetIds("minecraft:apple", "minecraft:bread", "minecraft:cooked_porkchop", "minecraft:cooked_fish", "minecraft:cookie", "minecraft:melon", "minecraft:cooked_beef", "minecraft:cooked_chicken", "minecraft:carrot", "minecraft:baked_potato",
                "minecraft:pumpkin_pie", "minecraft:cooked_mutton", "minecraftA:cooked_salmon", "minecraft:beetroot", "minecraft:beetroot_soup", "minecraft:dried_kelp", "minecraft:honey_bottle", "minecraft:cooked_rabbit", "minecraft:suspicious_stew", "minecraft:cooked_cod"
            );
```

* ...


---

# 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://docs.minecraftbot.com/api/id-system-item-and-block-ids.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.
