> For the complete documentation index, see [llms.txt](https://docs.aethercube.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aethercube.fr/developers/plugins/items-and-creatures.md). Agents can also search and read this documentation through its [MCP server](https://docs.aethercube.fr/~gitbook/mcp).

# Items and creatures

This page shows how to add your own items and creatures from a plugin. Both are data: you describe them, the server sends the description to clients, and a [content pack](https://docs.aethercube.fr/developers/content-packs/overview.md) provides their look. You never write client code or creature behaviour.

Rules that apply to both:

* Register in `onEnable`. Registration closes when the network starts and throws `IllegalStateException` afterwards.
* The key's namespace must not be `core` or `aethercube`: those are mine. Use your own, for example `skyglass:drift_shard`.
* A duplicate key throws `IllegalArgumentException`.
* Registrations belong to the plugin that made them (the `owner`, normally `this`).

## Items

```java
import com.velyorix.game.api.item.ItemCategory;
import com.velyorix.game.api.item.ItemDefinition;
import com.velyorix.game.api.item.Rarity;
import com.velyorix.game.api.util.NamespacedKey;
import java.util.Map;
import java.util.Set;

ItemDefinition shard = new ItemDefinition(
                new NamespacedKey("skyglass", "drift_shard"),
                "item.skyglass.drift_shard",
                Rarity.RARE,
                ItemCategory.MATERIAL,
                99,
                "skyglass:drift_shard",
                "skyglass:drift_shard",
                -1,
                Set.of(),
                Set.of(),
                Map.of("value", "12"))
        .withText("Driftglass Shard", "A sliver of an isle's keel.");

getServer().items().register(this, shard);
```

The arguments of the constructor, in order:

| Argument          | Meaning                                                                          |
| ----------------- | -------------------------------------------------------------------------------- |
| `key`             | `namespace:name`.                                                                |
| `nameKey`         | A localisation key. Clients read the text below for plugin items instead.        |
| `rarity`          | `COMMON`, `UNCOMMON`, `RARE`, `EPIC` or `LEGENDARY`.                             |
| `category`        | `BLOCK`, `TOOL`, `WEAPON`, `ARMOR`, `CONSUMABLE`, `MATERIAL`, `QUEST` or `MISC`. |
| `maxStack`        | 1 to 1000.                                                                       |
| `model`           | A model id from a pack, `namespace:name`, for the voxel model.                   |
| `icon`            | An icon id from a pack, `namespace:name`, for the inventory.                     |
| `placesMaterial`  | A block material id the item places, or `-1`.                                    |
| `equipmentSlots`  | A `Set<EquipmentSlot>` the item can be worn in. Hands accept any item.           |
| `allowedMetadata` | The metadata keys a stack may carry.                                             |
| `properties`      | Free-form gameplay properties as strings.                                        |

`withText(name, description)` sets the display name (up to 48 characters) and the description (up to 200). Clients show this text for plugin items, so always set it.

A plugin may register at most 10 000 items in all.

Other calls on `server.items()`: `get(key)` returns an `Optional<ItemDefinition>` and `all()` lists every item. `server.item(key)` is a shortcut for `get`.

### Giving items

The operator command is `give <player> <item> [amount]`. Without a namespace the item is looked up in `core`, so write `skyglass:drift_shard`.

### Creative menu and smelting

| Registry            | Use                                                                                                                                                            |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `creativeCatalog()` | `registerCategory(owner, id, name, iconItem, order)` and `addItem(owner, categoryId, itemKey)` to list items in the creative menu.                             |
| `smelting()`        | `addRecipe(owner, new Smelting.Recipe(id, input, output, outputCount, ticks))` and `addFuel(owner, new Smelting.Fuel(itemId, burnTicks))` for the Ember Forge. |

A plugin cannot register crafting recipes, crafting stations or repair rules yet. Only smelting recipes and fuels are exposed. If you need more, tell me.

## Creature types

A creature type copies the behaviour of an existing type, its archetype, and changes its key, size, statistics, speed, sight, experience, drops and disposition. You never write behaviour code.

Start from the archetype and change what you need:

```java
import com.velyorix.game.api.entity.CreatureDefinition;
import java.util.List;

CreatureDefinition moth = getServer().creatures()
        .get(new NamespacedKey("aethercube", "ambermoth"))
        .orElseThrow();

CreatureDefinition drifter = moth.toBuilder()
        .key(new NamespacedKey("skyglass", "keel_drifter"))
        .name("Keel Drifter")
        .size(1.1f, 1.0f)
        .model("skyglass:keel_drifter")
        .speeds(1.0, 1.6)
        .sight(12)
        .experience(18)
        .drops(List.of(new CreatureDefinition.Drop(
                new NamespacedKey("skyglass", "drift_shard"), 1, 2, 0.75)))
        .disposition(CreatureDefinition.Disposition.PASSIVE)
        .build();

getServer().creatures().register(this, drifter);
```

`CreatureDefinition.builder(key, archetype)` starts from nothing and needs every value.

| Builder method        | Limit                                                                                   |
| --------------------- | --------------------------------------------------------------------------------------- |
| `key(key)`            | Not in `core` or `aethercube`.                                                          |
| `name(text)`          | 1 to 48 characters.                                                                     |
| `size(width, height)` | Width above 0 up to 16. Height above 0 up to 64.                                        |
| `model(id)`           | A model id from a pack, or empty for a plain box.                                       |
| `stats(CombatStats)`  | Combat statistics at spawn.                                                             |
| `speeds(walk, run)`   | 0 to 32 blocks per second.                                                              |
| `sight(blocks)`       | 1 to 64.                                                                                |
| `range(blocks)`       | Melee reach, 0 to 16, default 1.6.                                                      |
| `experience(n)`       | 0 to 1 000 000.                                                                         |
| `drops(list)`         | At most 16 `Drop(item, min, max, chance)`.                                              |
| `disposition(d)`      | `PASSIVE`, `NEUTRAL` or `HOSTILE`.                                                      |
| `traits(TraitOdds)`   | The chances that the creature rolls each trait: strategist, fighter, fearful, sentinel. |

Registration throws `IllegalArgumentException` when the archetype is not a registered type, and when plugins already hold 1000 types. A type made from the mossback cannot be tamed or ridden: those stay tied to the mossback's exact key.

Other calls on `server.creatures()`: `get(key)`, `all()`, `ownedBy(owner)` and `spawn(type, world, x, y, z)`. `spawn` is for the simulation thread. See [Players, entities and creatures](https://docs.aethercube.fr/developers/plugins/players-entities-creatures.md).

`/summon <type>` accepts a plugin type, for example `/summon skyglass:keel_drifter`.

## Natural spawning

Add the type to a biome's spawn table. See [World, biomes and generation](https://docs.aethercube.fr/developers/plugins/world-biomes-and-generation.md).

## Shipping the look

The `model` and `icon` ids point into a content pack. A plugin ships its pack inside its jar. If the jar holds a folder `content/` with a `pack.json`, the server registers that pack when the plugin loads, as the Skyglass example does. A plugin can also register a pack by hand with `contentPacks().register(owner, directoryOrZip)` or `contentPacks().registerFromJar(owner, jar, folder)`. See [Content packs](https://docs.aethercube.fr/developers/content-packs/overview.md).

A creature with an empty `model` is drawn as a plain box of its size.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aethercube.fr/developers/plugins/items-and-creatures.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
