> For the complete documentation index, see [llms.txt](https://edseries-plugins.gitbook.io/p/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edseries-plugins.gitbook.io/p/pinnaprison/developers/edlib-api/models.md).

# Models

EdLib can render **custom multi-part 3D models** (BlockBench-style models built from display entities) with named animations. A model is registered in EdLib once (by id); your code then spawns lightweight, packet-based instances of it.

## Looking up a model

```java
EdModel model = EdLibAPI.getInstance().getModel("golem");
if (model == null) return; // not registered on this server
```

`EdModel`: `String getId()`, `Float getMaxHeight()` (tallest point — handy for floating a name above it), `EdModelEntity createEntity(Location location)`.

## Spawning and animating an instance

`createEntity` builds an `EdModelEntity` — a bundle of EdEntities (a main body, optional display name, interaction hitbox and named passenger parts) that move and animate together.

```java
EdModelEntity golem = model.createEntity(location);
golem.addWatcher(player);
golem.setGlowing(EdColor.GOLD);
golem.rotate(90f, 0f);
golem.spawn();

golem.playLoopAnimation("walk");   // loop until stopped
// …later
golem.playAnimation("attack");      // play once
golem.stopAnimation();

golem.remove();
```

| `EdModelEntity` method                                                      |                              |
| --------------------------------------------------------------------------- | ---------------------------- |
| `void spawn()`                                                              | Spawn for all watchers.      |
| `void addWatcher(Player p)`                                                 | Make it visible to a player. |
| `void remove()`                                                             | Despawn for everyone.        |
| `void setYaw(float)` / `setPitch(float)` / `rotate(float yaw, float pitch)` | Orient the whole model.      |
| `void setGlowing(EdColor color)`                                            | Glow outline.                |
| `void playAnimation(String name)`                                           | Play a named animation once. |
| `void playLoopAnimation(String name)`                                       | Loop a named animation.      |
| `void stopAnimation()`                                                      | Stop the current animation.  |
| `boolean isPlayingAnimation()` / `String getCurrentAnimation()`             | Animation state.             |

## Reaching the parts

You can grab the underlying [EdEntities](/p/pinnaprison/developers/edlib-api/entities.md) to drive them directly (e.g. give the main body [goals](/p/pinnaprison/developers/edlib-api/goals.md), or update the floating name):

| Method                                  |                                                                   |
| --------------------------------------- | ----------------------------------------------------------------- |
| `EdEntity getMainEntity()`              | The model's root entity — add goals here to move the whole model. |
| `EdEntity getDisplayName()`             | The floating-name entity (a text display — use `setText(...)`).   |
| `EdEntity getInteractionEntity()`       | The click hitbox.                                                 |
| `Map<String, EdEntity> getPassengers()` | The named sub-parts.                                              |
| `EdModel getModel()`                    | Back-reference to the source model.                               |

```java
golem.getMainEntity().addGoal(new EdGoalMove(target, 0.18));
golem.getDisplayName().setText(java.util.List.of("§6Stone Golem", "§7Lvl 5"));
```

{% hint style="info" %}
Models are registered on the EdLib side (exported model + animations). If `getModel(id)` returns `null`, the model isn't installed on that server — always null-check before spawning.
{% endhint %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edseries-plugins.gitbook.io/p/pinnaprison/developers/edlib-api/models.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.
