> For the complete documentation index, see [llms.txt](https://docs.jackf.red/chest-tracker/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jackf.red/chest-tracker/developer-guide/adding-button-positions.md).

# Adding Button Positions

How it works and adding your own defaults

When opening the GUI, Chest Tracker places the button based on the following criteria:

1. Where a user has manually moved it (stored under `chesttracker/user_button_positions.dat`)
2. From a position specified for that particular screen's class via resource pack (see below)
3. From the default position specified via resource pack (see below)
4. A hardcoded copy of the default position, if for whatever reason pack loading fails

{% hint style="info" %}

## Don't write it yourself!

Chest Tracker adds an export button which can be turned on in the global mod settings. This allows you to export the button's current position to the `chesttracker/export` directory, after dragging and positioning it yourself.
{% endhint %}

## Adding your own default positions

Position references are stored under `assets/<pack id>/chesttracker_button_positions`. Files consist of a list of screens to apply to, and a `position` object saying where to place the button based on anchor points and offsets.

{% hint style="info" %}
The file name doesn't matter; feel free to name it whatever you want for organisational purposes.
{% endhint %}

{% hint style="info" %}
Adding the class name `DEFAULT` will replace the default position for screens that don't have a registered position. This may be useful in the case of pack devs which are also shipping button-supplying mods.
{% endhint %}

For a practical example, take the shipped position for the enchanting table, which moves the button outside as to not overlap the top enchanting option:

```json
{
  // a list of java class names to apply this to.
  // This is generally intended for vanilla classes' intermediary and mojmap names,
  // but can be used to apply to multiple classes.
  // A special case is the class name 'DEFAULT', which is used as the generic fallback.
  "class_names": [ 
    "net.minecraft.class_486",
    "net.minecraft.client.gui.screens.inventory.EnchantmentScreen"
  ],
  // A definition consisting of X and Y anchor points and their offsets.
  "position": {
    "x_align": "right",
    "x_offset": 14,
    "y_align": "top",
    "y_offset": -11
  }
}
```

The valid options for `x_align`, as well as their `x_offset` behavior is as follows:

<table><thead><tr><th width="213">x_align</th><th width="267">Description</th><th>x_offset</th></tr></thead><tbody><tr><td><code>screen_left</code></td><td>Aligned to the left side of the window.</td><td>Pixels from the left of the screen.</td></tr><tr><td><code>screen_right</code></td><td>Aligned to the right side of the window.</td><td>Pixels from the right of the screen.</td></tr><tr><td><code>left_with_recipe</code></td><td>Aligned to the left side of the GUI. Moves left when a recipe book is open.</td><td>Pixels from the left of the GUI or Open Recipe Book, positive rightwards.</td></tr><tr><td><code>left</code></td><td>Aligned to the left side of the GUI. <strong>Does not</strong> move left when a recipe book is open.</td><td>Pixels from the left of the GUI, positive rightwards.</td></tr><tr><td><code>right</code></td><td>Aligned to the right side of the GUI.</td><td>Pixels from the left of the GUI, positive leftwards.</td></tr></tbody></table>

The valid options for `y_align`, as well as their `y_offset` behavior is as follows:

| y\_align        | Description                               | y\_offset                                            |
| --------------- | ----------------------------------------- | ---------------------------------------------------- |
| `screen_top`    | Aligned to the top side of the window.    | Pixels from the top of the screen.                   |
| `screen_bottom` | Aligned to the bottom side of the window. | Pixels from the bottom of the screen.                |
| `top`           | Aligned to the top side of the GUI.       | Pixels from the top of the GUI, positive downwards.  |
| `bottom`        | Aligned to the bottom side of the GUI.    | Pixels from the bottom of the GUI, positive upwards. |
