Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project

Boxed is a BentoBox GameModeAddon for Minecraft (Paper) where each player is confined to a small expandable box. Completing Minecraft advancements grows the box. Built against `bentobox` 3.23.7, Paper API 26.3, Java 25.
Boxed is a BentoBox GameModeAddon for Minecraft (Paper) where each player is confined to a small expandable box. Completing Minecraft advancements grows the box. Built against `bentobox` 3.25.0-SNAPSHOT, Paper API 26.3, Java 25.

## Build / Test

Expand All @@ -22,14 +22,23 @@ Surefire is configured with a long list of `--add-opens` JVM args required by Mo

Boxed is a BentoBox addon, not a standalone plugin. `Boxed` extends `GameModeAddon` and is loaded by BentoBox at runtime. `BoxedPladdon` is the Paper plugin-loader shim so Paper recognises the jar.

### The two-world "seed + game" generator model
### The "seed world -> template -> game world" generator model

This is the core concept and touches almost everything:

1. **Seed world** (`<worldname>/seed`, and `/seed_nether`): a real vanilla-ish world generated once using `BoxedSeedChunkGenerator` + `SeedBiomeGenerator` / `NetherSeedBiomeGenerator`. It's where Minecraft's normal terrain + structures (villages, shipwrecks, fortresses, etc.) actually get generated by the server.
2. **Game world** (`<worldname>`, `<worldname>_nether`): the world players actually play in. It uses `BoxedChunkGenerator` (a subclass of `AbstractBoxedChunkGenerator`) which does **not** generate terrain from scratch — instead, `Boxed.copyChunks(...)` pre-reads every chunk inside `islandDistance` from the seed world during `createWorlds()` and stores them in the chunk generator. When the game world asks for a chunk, the generator serves back the pre-captured copy.
1. **Seed world** (`<worldname>/seed`, and `/seed_nether`): a real vanilla-ish world generated using `BoxedSeedChunkGenerator` + `SeedBiomeGenerator` / `NetherSeedBiomeGenerator`. It's where Minecraft's normal terrain + structures actually get generated by the server. It is only loaded when a template has to be built.
2. **Template** (`generators/template`): `TemplateBuilder` captures every chunk inside `islandDistance` of the seed world into a `.bxt` file (`<data folder>/areas/<area>/normal.bxt`, `nether.bxt`) and `Boxed.loadTemplate()` then unloads the seed world. This happens once; later boots only open the file. `Template` reads block data from disk on demand (LRU of decoded `TemplateChunk`s) and keeps all biomes in memory. Deleting the `.bxt` files forces a rebuild.
3. **Game world** (`<worldname>`, `<worldname>_nether`): the world players actually play in. `BoxedChunkGenerator` does **not** generate terrain; it copies the template chunk at `repeatCalc(chunkX), repeatCalc(chunkZ)`, so every box is identical. `AbstractCopyBiomeProvider` and `BoxedBlockPopulator` read the same template.

This is why first boot is extremely slow and RAM-hungry (see `README.md` warnings): the entire seed region is force-loaded up front. Any change to world generation, structure handling, or world naming must respect both worlds and the copy step in `Boxed.copyChunks()` / `createOverWorld()` / `createNether()`. The `generatorMaps` / `generatorMap` fields in `Boxed.java` route world names → generators for `getDefaultWorldGenerator` (used by Multiverse and similar world-management plugins) and for the hook in `allLoaded()` that calls `WorldManagementHook.registerWorld`.
Never hold the whole region in memory or load the seed world on a normal boot — that is what made old versions need 12 GB and 10 minutes. Biome providers must return an accurate `getBiomes()` list: if a Nether provider claims overworld biomes are possible, the server searches for stronghold biomes before generating any chunk, which takes minutes. Any change to world generation, structure handling, or world naming must respect the seed world, the template format (`TemplateFile` magic/version) and the game world. The `generatorMaps` / `generatorMap` fields in `Boxed.java` route world names → generators for `getDefaultWorldGenerator` (used by Multiverse and similar world-management plugins) and for the hook in `allLoaded()` that calls `WorldManagementHook.registerWorld`.

### Areas

`areas/AreaManager` loads `areas.yml`. Each `Area` (seed, biomes file, structures file) has its own seed worlds (`<worldname>/seed_<id>`), its own templates (`areas/<id>/*.bxt`) and owns one east-west **row** of the box grid, persisted in `areas/grid.yml` and never reassigned. The generator, biome provider and populator pick the template from the chunk's z alone (`AbstractBoxedChunkGenerator.rowCalc` -> `Boxed.getTemplate(env, chunkZ)`), so anything that generates chunks must pass real game-world chunk coordinates, not folded ones. Boxes are placed by `AreaLocationStrategy`, returned from `Boxed.getNewIslandLocationStrategy(user, bundle)` (a BentoBox 3.25.0 hook): the blueprint bundle's unique id names the area, unknown bundles use `default`. The y of a box's centre comes from `areas/BoxHeight`: BentoBox pastes the starter blueprint with its bedrock at the centre, so the centre is set to land the blueprint's `[spawn_here]` sign on the area's ground (read from the template; falls back to the island-height setting). The nether blueprint is pasted at the same y, so it only lines up where the nether ground happens to match. Structure lists are per area via `Boxed.getStructuresFile(location)`. `AreaRules` refuses a box (by throwing from the hook, before anything is created) when the area is closed (`enabled: false`), is waiting for a restart, or is chained (`requires` + the required area's `unlocks-next-at` box size) and not yet unlocked, or the player already has a box in that area (one per area; the box being reset does not count). `/boxadmin areas` (`AdminAreasCommand`) lists, visits, creates and requests rebuilds of areas; creating and rebuilding only take effect at the next start because templates are built in `createWorlds()`.

### Deleted boxes

`listeners/BoxCleaner` restores a deleted (soft-deleted, `isDeletable()`) box's whole position from the template — generated chunks only, both dimensions, within a 10 ms per tick budget — then removes the island record so `AreaLocationStrategy` can hand the position out again (it always takes the first position in the row with no record). Do not rely on BentoBox's region-file purge for Boxed: it only deletes a region when every position overlapping it is deletable, and 640-block positions always share 512-block regions with neighbours. Deleted boxes are re-queued from the island cache on `BentoBoxReadyEvent`, so no extra persistence is needed.

### Advancements drive box size

Expand Down
Loading
Loading