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

# Example: Skyglass

Skyglass is the example plugin I wrote to show the whole content surface in one small project. Read it after [Getting started](https://docs.aethercube.fr/developers/plugins/getting-started.md) if you learn better from a complete plugin than from reference pages. It lives in the repository at `game-server/examples/skyglass/`, is about 23 KiB as a jar, and uses every part of the content surface: an item, a creature, a spawn entry, a loading backdrop, a terrain shader, a screen effect, models, icons and clips.

| Piece          | Id                                                                        |
| -------------- | ------------------------------------------------------------------------- |
| Item           | `skyglass:drift_shard`, "Driftglass Shard"                                |
| Creature       | `skyglass:keel_drifter`, "Keel Drifter", made from `aethercube:ambermoth` |
| Backdrop       | `skyglass:isles`                                                          |
| Screen effect  | `skyglass:updraft`                                                        |
| Terrain shader | A sheen on surfaces above y = 84, strongest by y = 120                    |

| Command              | Effect                                                              | Permission                    |
| -------------------- | ------------------------------------------------------------------- | ----------------------------- |
| `/drifter`           | Spawns a Keel Drifter four blocks ahead of you.                     | `skyglass.drifter`, operators |
| `/updraft [on\|off]` | Shows or clears the updraft on your screen, with a 1.5 second fade. | `skyglass.updraft`, everyone  |

## Layout

```
examples/skyglass/
├── build.gradle.kts
├── src/main/java/com/velyorix/examples/skyglass/
│   ├── Skyglass.java            the plugin
│   └── SkyglassContent.java     the item and creature definitions
├── src/main/resources/
│   ├── plugin.yml
│   ├── config.yml
│   └── content/                 the content pack
│       ├── pack.json
│       ├── models/              drift_shard/, keel_drifter/ (model.json and .vox)
│       ├── icons/drift_shard.png
│       ├── backdrops/isles.png
│       ├── animations/          five clips
│       ├── data/                item_models.json, entity_models.json, animations.json
│       └── shaders/             terrain.wgsl, updraft.wgsl
├── src/test/java/...            pack and plugin tests
└── tools/make_art.py            regenerates the art
```

## `plugin.yml`

```yaml
name: Skyglass
version: 1.0.0
main: com.velyorix.examples.skyglass.Skyglass
api-version: "1.0"
author: Aethercube
description: Driftglass from the keels of the floating isles, and the Keel Drifters that graze beneath them. An example plugin with a content pack.
load: POSTWORLD
permissions:
  skyglass.drifter:
    description: Spawn a Keel Drifter in front of you
    default: op
  skyglass.updraft:
    description: Show or clear the updraft screen effect
    default: true
commands:
  drifter:
    description: Spawns a Keel Drifter a few blocks in front of you
    usage: /drifter
    permission: skyglass.drifter
  updraft:
    description: Shows or clears the updraft screen effect on your screen
    usage: /updraft [on|off]
    permission: skyglass.updraft
```

## `config.yml`

```yaml
loading-backdrop: true
drifter-spawn-weight: 2
```

`loading-backdrop` sets the pack's `skyglass:isles` as the server's loading backdrop. `drifter-spawn-weight` is the natural spawn weight in `aethercube:aether_isles`. `0` turns the spawn off.

## The content, in code

`SkyglassContent` holds the ids and builds the definitions. The item:

```java
public static ItemDefinition driftShard() {
    return new ItemDefinition(
                    DRIFT_SHARD,
                    "item.skyglass.drift_shard",
                    Rarity.RARE,
                    ItemCategory.MATERIAL,
                    99,
                    "skyglass:drift_shard", // model: models/drift_shard of the pack
                    "skyglass:drift_shard", // icon: icons/drift_shard.png of the pack
                    -1,
                    Set.of(),
                    Set.of(),
                    Map.of("value", "12"))
            .withText("Driftglass Shard", "A sliver of an isle's keel. Set down, it still leans upward.");
}
```

The creature is built from its archetype, the ambermoth. It changes the box, the statistics, the speed, the sight, the experience and the drops, and makes the creature passive:

```java
public static CreatureDefinition keelDrifter(CreatureDefinition archetype) {
    CombatStats base = archetype.stats();
    CombatStats stats = new CombatStats(
            16f, 16f, 0f, 1f,
            base.criticalChance(), base.criticalMultiplier(), base.attackSpeed(), base.movementSpeed(),
            base.resistanceFire(), base.resistanceIce(), base.resistanceLightning(), base.resistancePoison());
    return archetype.toBuilder()
            .key(KEEL_DRIFTER)
            .name("Keel Drifter")
            .size(1.1f, 1.0f)
            .model("skyglass:keel_drifter") // models/keel_drifter of the pack
            .stats(stats)
            .speeds(1.0, 1.6)
            .sight(12)
            .experience(18)
            .drops(List.of(new CreatureDefinition.Drop(DRIFT_SHARD, 1, 2, 0.75)))
            .disposition(CreatureDefinition.Disposition.PASSIVE)
            .build();
}
```

## `onEnable`

```java
@Override
public void onEnable() {
    // The item and the creature type. Both must be registered before the network starts, so here.
    getServer().items().register(this, SkyglassContent.driftShard());
    CreatureDefinition archetype = getServer()
            .creatures()
            .get(SkyglassContent.ARCHETYPE)
            .orElseThrow(() -> new IllegalStateException(SkyglassContent.ARCHETYPE + " is not registered"));
    getServer().creatures().register(this, SkyglassContent.keelDrifter(archetype));

    // A rare sight in the isles. Spawn entries are not saved, so they are added at every start.
    int weight = getConfig().getInt("drifter-spawn-weight", 2);
    if (weight > 0) {
        if (getServer().biomes().get(SkyglassContent.ISLES_BIOME).isPresent()) {
            getServer().biomes().addSpawn(
                    this,
                    SkyglassContent.ISLES_BIOME,
                    new SpawnEntry(SkyglassContent.KEEL_DRIFTER, Math.min(weight, 1000), 1, 2));
        } else {
            getLogger().warn("no biome {}: the Keel Drifter will not spawn naturally", SkyglassContent.ISLES_BIOME);
        }
    }

    // The pack's backdrop on the loading screen, keeping whatever else the server set.
    if (getConfig().getBoolean("loading-backdrop", true)) {
        var screens = getServer().loadingScreens();
        screens.setDefaults(screens.defaults().toBuilder()
                .backdrop(SkyglassContent.BACKDROP)
                .build());
    }

    registerCommand("drifter", this::drifter);
    registerCommand("updraft", this::updraft);
}
```

The plugin never registers its content pack by hand. The server finds `content/pack.json` in the jar and registers the pack when the plugin loads.

## The commands

`/drifter` finds the player's entity and world, computes a point 4 blocks ahead and 1 block up, and spawns on the simulation thread, where commands already run:

```java
private CommandResult drifter(CommandContext c) {
    Player player = c.player().orElse(null);
    if (player == null) {
        return CommandResult.error("Only a player can call a Keel Drifter.");
    }
    Entity body = player.entity();
    if (body == null) {
        return CommandResult.error("You are not in the world yet.");
    }
    World world = getServer().world(body.world()).orElse(null);
    if (world == null) {
        return CommandResult.error("Your world is not loaded.");
    }
    Vector3 at = inFront(body.position(), body.yaw());
    getServer().creatures().spawn(SkyglassContent.KEEL_DRIFTER, world, at.x(), at.y(), at.z());
    return CommandResult.ok("A Keel Drifter drifts in.");
}
```

`/updraft` checks that the pack really loaded, because `show` throws for an effect that no pack declares:

```java
private CommandResult updraft(CommandContext c) {
    Player player = c.player().orElse(null);
    if (player == null) {
        return CommandResult.error("Only a player has a screen.");
    }
    if (!getServer().contentPacks().screenEffects().contains(SkyglassContent.UPDRAFT)) {
        return CommandResult.error("The Skyglass pack is not loaded on this server.");
    }
    boolean on = !c.has(0) || c.bool(0);
    getServer().screenEffects().show(player, on ? UPDRAFT_ON : UPDRAFT_OFF);
    return CommandResult.ok(on ? "The updraft rises." : "The updraft settles.");
}
```

The two effect values are built once:

```java
static final ScreenEffect UPDRAFT_ON = ScreenEffect.builder()
        .effect(SkyglassContent.UPDRAFT)
        .intensity(0.8f)
        .params(1.0f)       // params[0].x of the shader: the strength
        .fadeSeconds(1.5f)
        .build();

static final ScreenEffect UPDRAFT_OFF =
        ScreenEffect.builder().effect("").fadeSeconds(1.5f).build();
```

## The pack

`content/pack.json` declares what the pack adds:

```json
{
  "format": 1,
  "namespace": "skyglass",
  "name": "Skyglass",
  "version": "1.0.0",
  "description": "Driftglass from the keels of the floating isles, and the creatures that graze on light beneath them.",
  "backdrops": { "isles": { "file": "backdrops/isles.png", "place": "The Skyglass Isles" } },
  "terrain_shader": "shaders/terrain.wgsl",
  "screen_effects": { "updraft": "shaders/updraft.wgsl" }
}
```

The `data/` files bind the models to the item and the creature, and the clips to states:

`data/item_models.json` gives the item its model and the socket it is held by:

```json
{ "version": 1, "items": { "skyglass:drift_shard": { "model": "skyglass:drift_shard", "socket": "right_hand_upright" } } }
```

`data/entity_models.json` gives the creature its model:

```json
{ "version": 1, "entities": { "skyglass:keel_drifter": "skyglass:keel_drifter" } }
```

`data/animations.json` binds clips to states:

```json
{
  "version": 1,
  "models": {
    "skyglass:drift_shard": { "idle": "animations/shard_bob.json" },
    "skyglass:keel_drifter": {
      "idle": "animations/drifter_idle.json",
      "walk": "animations/drifter_drift.json",
      "fly": "animations/drifter_drift.json",
      "hit": "animations/drifter_hit.json",
      "death": "animations/drifter_death.json"
    }
  }
}
```

The files `models/*/model.json`, the shaders and the clips are shown on the pages of [Content packs](https://docs.aethercube.fr/developers/content-packs/overview.md): [Models](https://docs.aethercube.fr/developers/content-packs/models.md), [Animations](https://docs.aethercube.fr/developers/content-packs/animations.md) and [Shaders](https://docs.aethercube.fr/developers/content-packs/shaders.md).

## Build and run

```sh
cd game-server
./gradlew :examples:skyglass:jar
cp examples/skyglass/build/libs/skyglass-*.jar /path/to/my-server/plugins/
```

Start the server, join, and try:

```
/drifter
/updraft
/updraft off
/give <you> skyglass:drift_shard 5
```

`./gradlew :examples:skyglass:check` runs the tests. They build the pack with the server's own pack builder, so a broken pack fails the build.


---

# 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/example-skyglass.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.
