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
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Never hold the whole region in memory or load the seed world on a normal boot

`reach/` answers whether an area can be played. `LandSurvey` counts, per box size, the blocks, biomes and template entities of an area's templates plus the starter blueprint and the structures file. `Requirements` reads `requirements.yml`, a hand-written model of what each scored advancement needs (and `provides` rules that turn biomes and structures into mobs). `GrowthSimulator` earns everything in reach, grows the box by the scores and repeats; `ReachReport` writes it up. `/boxadmin areas check <area>` runs the survey off the main thread. Every advancement with a score in `advancements.yml` must have an entry in `requirements.yml` (a test enforces it).

### Finding a place to start

`/boxadmin areas find <area> [seed|random] [radius]` (`AdminAreasFindCommand`) looks for good spots in a seed. `reach/SpotFinder` searches the vanilla biomes (no chunks needed) for wooded land with water nearby; the best few are generated in a throwaway `<worldname>/finder_<time>` world, using the area's biomes file laid out around every spot at once (`AbstractSeedBiomeProvider.setCentres`), and scored by `reach/SpotSurvey` (dry middle, then the box size that takes in logs, surface water, shallow stone, iron ore and coal). The world is unloaded without saving and deleted. An area uses a spot through `centre: x,z` in `areas.yml` (`Area.centreX/centreZ`, overworld only; the Nether template is still taken from 0,0).

### 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.
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ You can also do the same by hand: add the area to `areas.yml` and make a bluepri
| `/boxadmin areas` | Lists the areas with their row, seed and number of boxes. |
| `/boxadmin areas tp <area>` | Takes you to the land where the area's next box will be, so you can look at it and place structures before any player has a box there. |
| `/boxadmin areas create <name> [seed]` | Makes a new area and its blueprint bundle. Needs a restart. |
| `/boxadmin areas rebuild <area> [regenerate]` | Builds the area's land again at the next restart. With `regenerate` the seed worlds are thrown away first, which is needed after changing the area's seed or biomes. Without it, the land is rebuilt from the seed worlds as they are, which keeps changes made to them by hand. |
| `/boxadmin areas rebuild <area> [regenerate]` | Builds the area's land again at the next restart. With `regenerate` the seed worlds are thrown away first, which is needed after changing the area's seed, centre or biomes. Without it, the land is rebuilt from the seed worlds as they are, which keeps changes made to them by hand. |
| `/boxadmin areas clean [x z]` | Puts the land of the box position you are in (or the one at x, z) back the way it was. Use it after trying out structures in a position nobody has a box in. Positions with a box in use are refused. |
| `/boxadmin areas check <area>` | Plays out how a box grows in the area and reports where players get stuck. See [Checking that an area can be played](#checking-that-an-area-can-be-played). |
| `/boxadmin areas find <area> [seed\|random] [radius]` | Looks through a seed for good places to start a box. See [Finding a good place to start](#finding-a-good-place-to-start). |

Areas can be chained so that a player's box in one area has to reach a certain size before the next area is unlocked, and can be closed to new boxes:

Expand Down Expand Up @@ -164,6 +165,27 @@ What each advancement needs is set in `requirements.yml`, which is written to th

An advancement that scores points but can never be earned is worth either removing from `advancements.yml` or making possible, for example by placing a structure with `/boxadmin place`.

### Finding a good place to start

Every box in an area is a copy of the land around one place in the area's seed. By default that place is 0,0, so whether new players start in a forest or in the sea depends on the seed. `/boxadmin areas find <area> [seed|random] [radius]` finds better places for you:

* with no seed it searches the seed the area already has, so you can see how the current place compares,
* with a seed it searches that seed, and with `random` it picks a new seed,
* `radius` is how far from 0,0 to search in blocks. The default is 5000.

The search looks for dry, wooded land with a river or the sea a short walk away. It then generates the land around the best dozen places in a temporary world, which is deleted afterwards, and gives each a score out of 100. The score is highest when the middle is dry land and a small box already holds logs, water at the surface, stone near the surface, iron ore and coal. The area's biomes file is used, so the land is what a box there would really have. It takes around 10 seconds.

The three best places are shown and the full list is written to `areas/<area>/spots.txt`:

```
100/100 centre: 1664,1536 (forest, river or sea about 32 blocks away, 92% land)
dry land (100% dry), wood at size 4, water at size 14, stone at size 1, iron ore at size 2, coal at size 2
```

To use a place, set the area's `seed` and `centre` in `areas.yml`, run `/boxadmin areas rebuild <area> regenerate` and restart the server. Boxes that players have already explored do not change, so do this before the area is in use. `centre` moves the overworld only. The Nether of an area is always taken from 0,0 of its seed.

A good start does not mean the area can be finished. Run `/boxadmin areas check <area>` after the restart to see how far a box there can grow.


### biomes.yml
The player's land has biomes and they are defined here. It's not possible to define where the biomes are right now, only what affect they have on the terrain.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/world/bentobox/boxed/Boxed.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private boolean loadSettings() {
String worldName = settings.getWorldName().toLowerCase(Locale.ENGLISH);
for (Area area : areas.getAreas()) {
generatorMaps.put(area.seedWorldName(worldName, false), new BoxedSeedChunkGenerator(this,
Environment.NORMAL, new SeedBiomeGenerator(this, area.biomes())));
Environment.NORMAL, new SeedBiomeGenerator(this, area.biomes(), area.centreX(), area.centreZ())));
generatorMaps.put(area.seedWorldName(worldName, true), new BoxedSeedChunkGenerator(this,
Environment.NETHER, new NetherSeedBiomeGenerator(this, area.biomes())));
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public void createWorlds() {
// Get the land of every area ready before the game worlds ask for it
for (Area area : areas.getAreas()) {
boolean regenerate = checkRebuildRequest(area);
loadTemplate(area, worldName, Environment.NORMAL, settings.getSeedX(), settings.getSeedZ(), regenerate);
loadTemplate(area, worldName, Environment.NORMAL, area.centreX(), area.centreZ(), regenerate);
if (settings.isNetherGenerate()) {
loadTemplate(area, worldName, Environment.NETHER, settings.getNetherSeedX(),
settings.getNetherSeedZ(), regenerate);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/world/bentobox/boxed/areas/Area.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
* @param unlockSize the size a player's box in this area must reach to unlock the areas that
* require it. Each area sets its own, so some can be harder than others.
* 0 means that just having a box in the area is enough.
* @param centreX block x in the overworld seed world that the middle of every box is taken from
* @param centreZ block z in the overworld seed world that the middle of every box is taken from
* @author tastybento
*/
public record Area(String id, long seed, String biomes, String structures, int row, boolean enabled,
String requires, int unlockSize) {
String requires, int unlockSize, int centreX, int centreZ) {

/**
* Name of the area that always exists
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/world/bentobox/boxed/areas/AreaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ public AreaManager(YamlConfiguration config, File gridFile, long defaultSeed,
s = new YamlConfiguration();
}
String requires = getRequirement(s, id, ids, errorLog);
int[] centre = parseCentre(s.getString("centre", s.getString("center", "")), id, errorLog);
Area area = new Area(id, s.getLong("seed", defaultSeed), s.getString("biomes", "biomes.yml"),
s.getString("structures", "structures.yml"), grid.getInt(path), s.getBoolean("enabled", true),
requires, Math.max(0, s.getInt("unlocks-next-at", 0)));
requires, Math.max(0, s.getInt("unlocks-next-at", 0)), centre[0], centre[1]);
areas.put(id, area);
areaByRow.put(area.row(), area);
}
Expand All @@ -80,6 +81,28 @@ public AreaManager(YamlConfiguration config, File gridFile, long defaultSeed,
}
}

/**
* Reads where in the seed world the middle of an area is. Land is copied in whole chunks,
* so the spot is moved to the corner of its chunk.
* @param text "x,z", or empty for the middle of the seed world
* @return block x and z
*/
static int[] parseCentre(String text, String id, java.util.function.Consumer<String> errorLog) {
if (text.isBlank()) {
return new int[] { 0, 0 };
}
String[] xz = text.split(",");
try {
if (xz.length == 2) {
return new int[] { Integer.parseInt(xz[0].trim()) >> 4 << 4, Integer.parseInt(xz[1].trim()) >> 4 << 4 };
}
} catch (NumberFormatException _) {
// Reported below
}
errorLog.accept("Area " + id + ": centre must be two whole numbers like 1200,-640. Using 0,0.");
return new int[] { 0, 0 };
}

/**
* Lists the names of the areas in the config. The default area always exists and always
* comes first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void setup() {
new Rebuild(this);
new Clean(this);
new Check(this);
new AdminAreasFindCommand(this);
}

@Override
Expand Down
Loading
Loading