# Items Stacker

## Stacking Algorithm

The plugin uses a simple but efficient way of stacking items together:

#### Stacking Trigger occurs

There are plenty of triggers that will cause the plugin to attempt and stack two items together. This is the first step in the stacking process, and more about the triggers can be found below.

#### Nearby Items Check

The plugin will look for nearby items, and proceed to the next step. Only nearby items that meet range criteria will be potential items to be stacked. The plugin will cache the results for 5 seconds so items lookups can be more optimized.

#### Item Similar Check

The plugin will attempt to stack two items together only if they are similar in their item types, metadata and the only difference between the items is their amount.

#### Stacking Items

The last and most important step. The plugin will stack the two items together: it will take the amount of the first stack and add it to the second. Then it will remove the first one from the world, and play a nice partical.

## Stacking Triggers

The plugin will attempt to stack items when one of the following events occur:

* Item spawns into the world.
* Every cycle of the stack-task of items.
* Two entities are naturally merging (vanilla's mechanism of merging items)


---

# 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://wiki.bg-software.com/wildstacker/overview/items-stacker.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.
