# Data packs

Add play styles and difficulties, tune bots' tags, and teach them to build your own house designs.

import { FileTree, Steps } from '@prosefly/astro-components';

Everything that shapes a bot's personality is data: play styles, difficulties, a few item and entity tags, and
building templates. You can change all of it with a regular data pack, no coding needed.

## Layout

A data pack for AI Players looks like this:

<FileTree>

- mypack
  - pack.mcmeta
  - data
    - mypack
      - aiplayers
        - playstyle
          - builder.json `mypack:builder`
        - difficulty
          - veteran.json `mypack:veteran`
        - potion
          - regeneration.json `mypack:regeneration`
      - structure
        - house.nbt `mypack:house`
    - aiplayers
      - tags
        - item
          - harmful_food.json
        - entity_type
          - prey.json
          - huntable_monsters.json

</FileTree>

Put the pack in your world's `datapacks` folder and run `/reload` (or `/aiplayer profile reload` for play styles
and difficulties alone). Then check `/aiplayer profile list`. It shows every loaded profile with the pack it came
from, and every file that failed to load with the reason.

- Play style format: [Play style files](/ai-players/reference/play-style-files/).
- Difficulty format: [Difficulty files](/ai-players/reference/difficulty-files/).

## Changing a shipped preset

A data pack can replace a shipped play style or difficulty by providing a file with the same id, for example
`data/aiplayers/aiplayers/playstyle/rusher.json`. As with any data pack, the pack loaded last wins.

## Tags

AI Players reads three tags. Add to them with `"replace": false`, as usual:

| Tag | Default contents | Used for |
| :-- | :--------------- | :------- |
| `#aiplayers:harmful_food` (item) | raw chicken, rotten flesh, spider eye, pufferfish, poisonous potato | Food bots never eat (unless starving below food level 4). |
| `#aiplayers:prey` (entity type) | cow, pig, sheep, chicken, rabbit, mooshroom | Animals bots may hunt for food and drops. |
| `#aiplayers:huntable_monsters` (entity type) | zombie, skeleton, spider, creeper, enderman, silverfish, blaze, magma_cube, wither_skeleton | Monsters bots hunt for their drops (string, bones, gunpowder, ender pearls, blaze rods, magma cream, coal) or fight on their way (silverfish in a stronghold). |

```json title="data/aiplayers/tags/item/harmful_food.json"
{
  "replace": false,
  "values": ["minecraft:suspicious_stew"]
}
```

:::note
Bots know what the vanilla prey animals drop. For any other animal (a modded one, say), adding it to
`#aiplayers:prey` isn't enough. Its mod also has to tell AI Players what it drops (see
[Mod integration](/ai-players/reference/mod-integration/)). The same goes for modded monsters in
`#aiplayers:huntable_monsters`.
:::

Bots also understand the usual vanilla and common tags: modded logs in `#minecraft:logs`, iron and copper ores in
`#minecraft:iron_ores` and `#minecraft:copper_ores`, every ore tag under `#c:ores/` (each becomes an ore the bots
know, mined with the lowest vanilla pickaxe that gets its drops, at the height a play style's `mining.ore_heights`
gives it), modded crops in `#minecraft:crops`, and `#c:gems/lapis` for enchanting. A data pack that adds a mod's
ore to a `#c:ores/<name>` tag, or its crop to `#minecraft:crops`, teaches bots that much without a plugin. See
[Mod integration](/ai-players/reference/mod-integration/) for what needs one.

## Potions

A data pack can teach bots new brewing chains by adding files at:

```txt title="Path"
data/<namespace>/aiplayers/potion/<name>.json
```

Once defined, a play style can list that potion in its `nether.potions` stock map (see
[Play style files](/ai-players/reference/play-style-files/#nether)).

```json title="data/mypack/aiplayers/potion/regeneration.json"
{
  "potion": "minecraft:regeneration",
  "base": "minecraft:awkward",
  "ingredient": "minecraft:ghast_tear",
  "extended": true
}
```

| Key | Type | Description |
| :-- | :--- | :---------- |
| `potion` | potion id | The vanilla potion the step produces (e.g. `minecraft:regeneration`). |
| `base` | potion id | The base potion in the three bottles (`minecraft:water` is filled at water; any other potion is brewed first by its own chain). |
| `ingredient` | item id | The brewing reagent that turns `base` into `potion` (e.g. `minecraft:ghast_tear`). |
| `extended` | boolean (optional) | When `true`, adds a redstone dust step so the chain yields `long_<potion>` (which is the id to name in `nether.potions`). Cannot be combined with `strong`. |
| `strong` | boolean (optional) | When `true`, adds a glowstone dust step so the chain yields `strong_<potion>`. Cannot be combined with `extended`. |

Seven brewing chains ship under `aiplayers`: `awkward`, `fire_resistance`, `strength`, `swiftness`, `night_vision`,
`invisibility` and `healing`. If vanilla doesn't brew a chain, the bot refuses it at the stand before moving
anything.

## Custom buildings

A play style can make bots build your own house or storehouse design instead of the generated one. The bot still
uses its own blocks (its planks, logs, cobblestone and glass). Your template sets the shape and where the
furniture goes.

<Steps>

1. **Build it in creative mode**, following the rules:

   - Walls of full blocks under a flat roof.
   - An odd width and depth (5×7, 7×7...).
   - Exactly one door.
   - Only full blocks, glass, doors, beds, chests, torches, crafting tables and furnaces.
   - Nothing inside but a bed, a chest, a torch, a crafting table or a furnace.
   - The eight top corners (the roof's four and the top wall layer's four) must be full blocks.

2. **Save it with a structure block** named `mypack:house`. The box goes from the first wall layer up to the
   roof, without the floor. The file lands in your world's `generated/mypack/structure/house.nbt`.

3. **Copy it into your data pack** at `data/mypack/structure/house.nbt`.

4. **Name it in a play style:**

   ```json title="playstyle.json (excerpt)"
   "base": { "structures": { "house": "mypack:house", "storehouse": "mypack:storehouse" } }
   ```

</Steps>

How a template is read:

- A **log** is a corner column, **glass** is a window, the **top layer** is the roof, and any other full block is
  wall. The bot fills them with what it has.
- It's built as saved, without rotating it, so the door faces the same way it did when you saved it.
- A template that breaks a rule is refused with one line in the server log naming the rule and the block. Bots
  then use the generated building instead.

AI Players ships one template, `aiplayers:cabin`, a 5×5 plank house.

:::note[Known limits]
Templates can't have a second floor, a skylight, more than one door, or anything inside the walls beyond the
furniture listed above. A storehouse template is placed on a square site like the generated one.
:::
