> 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/players-entities-creatures.md). Agents can also search and read this documentation through its [MCP server](https://docs.aethercube.fr/~gitbook/mcp).

# Players, entities and creatures

How to look up players, entities and worlds from a plugin, and what you can do with them. Everything here lives under `com.velyorix.game.api`. Entities are views, not objects you mutate: changes go through the registries described below.

## Finding things

| Call on `Server`     | Returns                                     |
| -------------------- | ------------------------------------------- |
| `onlinePlayers()`    | The players in the world.                   |
| `player(name)`       | `Optional<? extends Player>` by name.       |
| `entity(id)`         | `Optional<? extends Entity>` by entity id.  |
| `world(name)`        | `Optional<? extends World>`.                |
| `loadedWorlds()`     | The loaded worlds. A server runs one world. |
| `defaultWorld()`     | The name of the world players spawn in.     |
| `broadcast(message)` | Send a line to every player.                |
| `version()`          | The game version.                           |

## Player

`Player` extends `CommandSender`.

| Method                        | Meaning                                                                                                      |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `playerId()`                  | A stable id. An account id in online mode, `offline:<uuid>` in offline mode.                                 |
| `username()`, `displayName()` | The names. `name()` is the username.                                                                         |
| `authenticated()`             | Whether the identity was verified by the backend.                                                            |
| `entity()`                    | The player's `Entity`, or `null` before the player has joined the world.                                     |
| `gameMode()`                  | `SURVIVAL`, `CREATIVE` or `SPECTATOR`.                                                                       |
| `setGameMode(mode)`           | Changes the mode on the simulation thread. Returns whether it changed. It fires `PlayerGameModeChangeEvent`. |
| `sendMessage(text)`           | Send a line.                                                                                                 |
| `hasPermission(node)`         | Check a node.                                                                                                |

Always check `entity()` for `null` when your code can run before the join completes.

## Entity

An `Entity` is a read-only view of anything in the world: players, creatures, bosses, NPCs, dropped items.

| Method                     | Meaning                                                                                                                                                     |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id()`, `uuid()`           | Identifiers. The id is the number used in commands.                                                                                                         |
| `definition()`             | An `EntityDefinition`. Its category is one of `PLAYER`, `CREATURE`, `BOSS`, `NPC`, `PROJECTILE`, `DROPPED_ITEM`, `INTERACTIVE_OBJECT`, `VEHICLE`, `CUSTOM`. |
| `world()`                  | The world name.                                                                                                                                             |
| `position()`, `velocity()` | A `Vector3` (`x()`, `y()`, `z()`). The position is the entity's feet.                                                                                       |
| `yaw()`, `pitch()`         | Orientation in radians.                                                                                                                                     |
| `grounded()`               | Whether it stands on a block.                                                                                                                               |
| `boundingBox()`            | An `AABB`.                                                                                                                                                  |
| `state()`                  | `CREATED`, `INITIALIZED`, `SPAWNING`, `ACTIVE`, `DESPAWNING` or `REMOVED`. `inWorld()` is true for `ACTIVE`.                                                |
| `revision()`               | Increases when the entity changes.                                                                                                                          |

To change entities, use the registries: `effects()`, `progression()`, `creatures()` and the commands. The entity view itself has no setters.

## World

| Method                                                                    | Meaning                                                                                                                                  |
| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `name()`, `seed()`                                                        | The name and the generation seed.                                                                                                        |
| `generatorId()`, `generatorVersion()`                                     | The generator the world was created with.                                                                                                |
| `biomeAt(x, y, z)`                                                        | A `BiomeDefinition`.                                                                                                                     |
| `regionNameAt(x, y, z)`                                                   | The name of the region, or an empty string.                                                                                              |
| `weather()`, `weatherTicksLeft()`, `weatherIntensity()`, `weatherCycle()` | Weather state. `Weather` is `CLEAR`, `RAIN` or `THUNDER`.                                                                                |
| `setWeather(weather, ticks)`                                              | Set the weather for a number of ticks.                                                                                                   |
| `difficulty()`, `setDifficulty(d)`                                        | `PEACEFUL`, `EASY`, `NORMAL` or `HARD`.                                                                                                  |
| `border()`, `setBorder(b)`                                                | A `WorldBorder(centerX, centerZ, diameter, damagePerBlock)`. The constructor validates the ranges and throws `IllegalArgumentException`. |

The block API of the server is the set of block events. A plugin changes blocks through the events it can cancel and, for generation, through a [generator](https://docs.aethercube.fr/developers/plugins/world-biomes-and-generation.md).

## Creatures

A creature type is data: a key, a box, statistics, drops and the archetype whose behaviour it copies. See [Items and creatures](https://docs.aethercube.fr/developers/plugins/items-and-creatures.md) to define one.

To spawn a creature:

```java
Entity moth = getServer().creatures().spawn(
        new NamespacedKey("aethercube", "ambermoth"), world, x, y, z);
```

`spawn` returns the new `Entity`. It must run on the simulation thread. It throws `IllegalStateException` anywhere else or when the world is not open, and `IllegalArgumentException` for an unknown type or a world that is not loaded.

Operators can also use `/summon`. Wild creatures spawn around players from the biome tables when `creatures.enabled` is on. See [World, biomes and generation](https://docs.aethercube.fr/developers/plugins/world-biomes-and-generation.md).

`server.creatureTraits(entity)` returns the `CreatureTrait` set a creature rolled when it spawned, and an empty set for other entities. A creature spawned with `spawn` is alone in its pack and has no traits.

## Damage and effects

Damage events carry a `DamageSource`: a `Kind` (`ENTITY_ATTACK`, `ABILITY`, `FALL`, `ENVIRONMENT`, `PLUGIN`, `EFFECT`), the source entity id, the weapon, a `DamageType` and a skill multiplier. Use `EntityDamageEvent` to change or cancel the amount.

Status effects are in `server.effects()`:

| Method                                         | Effect                                                                                                                 |
| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `apply(entity, key, amplifier, durationTicks)` | Returns a `Result`: `APPLIED`, `REPLACED`, `KEPT`, `CANCELLED`, `LIMIT_REACHED`, `UNKNOWN_EFFECT` or `NOT_APPLICABLE`. |
| `remove(entity, key)`, `clear(entity)`         | Remove one effect or all.                                                                                              |
| `active(entity)`                               | The active effects.                                                                                                    |
| `register(owner, effect)`                      | Add an effect type.                                                                                                    |

Limits: duration up to 72 000 ticks, amplifier up to 255, 16 effects per entity.

Progression is in `server.progression()`: `level(player)`, `experience(player)`, `giveExperience(player, amount)` and `setLevel(player, level)`.


---

# 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/players-entities-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.
