QtCraft API C++ classes QML types Handbook

QcWorldGenerator Class

Produces the unmodified terrain of a chunk from the world seed. More...

Header: #include <worldgen/generators/QcWorldGenerator.h>
Inherited By:

QcFlatGenerator, QcShowcaseGenerator, QcTerrainGenerator, QcTestTerrainGenerator, and QcVoidGenerator

Public Functions

virtual ~QcWorldGenerator()
virtual QString biomeAt(int x, int z) const
virtual QcChunkFurnishing furnishingIn(QcChunkPos pos) const
virtual std::shared_ptr<QcChunk> generate(QcChunkPos pos) const = 0
virtual bool isNaturalGround(QcBlockId block) const
virtual QList<QcWorldLabel> labelsIn(QcChunkPos pos) const
virtual QStringList locatableNames() const
virtual QcLocateResult locate(QStringView kind, QcBlockPos from, int reach) const
virtual std::optional<QcStructurePlacement> nearestStructure(const QString &name, QcBlockPos from, int reach) const
virtual std::shared_ptr<const QcVillagePlan> nearestVillage(QcBlockPos from, int reach) const
virtual std::optional<QcStructureSites> plannedStructureSitesNear(QcBlockPos from, int reach) const
virtual std::optional<QcBlockId> platformBlock() const
virtual QList<QcBlockPos> pointsOfInterestIn(QcChunkPos pos) const
virtual void setVersion(int version)
virtual QcWorldSetup setup() const
virtual QcBlockPos spawnPoint() const = 0
virtual QcStructureSites structureSitesNear(QcBlockPos from, int reach) const
int version() const
virtual std::shared_ptr<const QcVillagePlan> villageFor(QcChunkPos pos) const
const QStringList &warnings() const

Protected Variables

QStringList m_warnings

Detailed Description

Implementations must be deterministic and safe to call from several threads at once.

Member Function Documentation

[virtual noexcept default] QcWorldGenerator::~QcWorldGenerator()

Destroys the instance of QcWorldGenerator. This destructor is virtual.

[virtual] QString QcWorldGenerator::biomeAt(int x, int z) const

Returns the name of the biome of the column x, z; empty for generators without biomes.

[virtual] QcChunkFurnishing QcWorldGenerator::furnishingIn(QcChunkPos pos) const

Returns the chest loot, spawner kinds and minecarts of the chunk pos (decision E-520), in world coordinates; the server puts them in when the chunk first arrives. Empty for generators without any.

[pure virtual] std::shared_ptr<QcChunk> QcWorldGenerator::generate(QcChunkPos pos) const

Returns the generated chunk at pos.

[virtual] bool QcWorldGenerator::isNaturalGround(QcBlockId block) const

Returns whether a player may spawn standing on block: ground of the terrain itself, not a tree, plant or liquid. Generators without that knowledge accept every block.

[virtual] QList<QcWorldLabel> QcWorldGenerator::labelsIn(QcChunkPos pos) const

Returns the labels floating in the chunk pos (decision E-222); the server sends them with the chunk.

[virtual] QStringList QcWorldGenerator::locatableNames() const

Returns the words /locate takes for this generator (decision E-911): "village", the kinds of places locate() finds ("mineshaft", "dungeon", "coastal_tower") and the structures it places by itself (nearestStructure(), the base game's without "qtcraft:"); empty for generators without any.

[virtual] QcLocateResult QcWorldGenerator::locate(QStringView kind, QcBlockPos from, int reach) const

Returns the place of kind kind ("mineshaft", "dungeon", "coastal_tower") nearest to from within about reach blocks, if any, and how far the search looked (it may stop short of reach within its budget of planned regions); no place for other words.

[virtual] std::optional<QcStructurePlacement> QcWorldGenerator::nearestStructure(const QString &name, QcBlockPos from, int reach) const

Returns the placed copy of the structure name that the generator places by itself (decision E-590), alone or as a village piece (the temple at a desert village's centre, E-592), nearest to from within about reach blocks (whole regions), if any.

[virtual] std::shared_ptr<const QcVillagePlan> QcWorldGenerator::nearestVillage(QcBlockPos from, int reach) const

Returns the village whose centre lies nearest to from, at most about reach blocks away.

[virtual] std::optional<QcStructureSites> QcWorldGenerator::plannedStructureSitesNear(QcBlockPos from, int reach) const

Returns the same as structureSitesNear() for from and reach from the plans made so far, never planning (the server's tick thread asks this); std::nullopt when a region within reach is not planned yet (structureSitesNear plans it, on a generation thread). Generators whose plans are all made up front answer structureSitesNear.

[virtual] std::optional<QcBlockId> QcWorldGenerator::platformBlock() const

Returns the block of the generator's own spawn platform; the server puts one under a spawn without any ground (decision E-288). Without one it takes stone.

[virtual] QList<QcBlockPos> QcWorldGenerator::pointsOfInterestIn(QcChunkPos pos) const

Returns the beds and workstations the generator places in the chunk pos outside every village plan that count as placed by a player (decision E-490): the server notes each one with the village state when the chunk enters the world (QcVillages::notePointOfInterest), so it joins a village near it or founds a settlement. The showcase's stations; empty for other generators.

[virtual] void QcWorldGenerator::setVersion(int version)

Sets the world generator version it generates as to version; a generator whose parts keep a version of their own passes it on (before anything is generated).

See also version().

[virtual] QcWorldSetup QcWorldGenerator::setup() const

Returns what is set up once when a world is created (rules, creatures, contents, updates; decision E-221).

[pure virtual] QcBlockPos QcWorldGenerator::spawnPoint() const

Returns the feet position for a new player near the world origin.

[virtual] QcStructureSites QcWorldGenerator::structureSitesNear(QcBlockPos from, int reach) const

Returns the guardian zones (decision E-591) and spawn areas (decision E-871) of the structures within about reach blocks of from (whole regions); empty for generators without any.

int QcWorldGenerator::version() const

Returns the world generator version it generates as (decision E-922, QcGeneratorVersion); set by QcWorldGenerators::create, the current one for generators made directly. The server opens a world only with a generator of the world's version.

See also setVersion().

[virtual] std::shared_ptr<const QcVillagePlan> QcWorldGenerator::villageFor(QcChunkPos pos) const

Returns the village of the region that holds the chunk pos (decision E-403); null without one or for generators without villages.

const QStringList &QcWorldGenerator::warnings() const

Returns what could not be resolved when the generator was made (unknown blocks or structures, replaced by fallbacks or left out); its creator reports it.

Member Variable Documentation

QStringList QcWorldGenerator::m_warnings

Filled by the constructors of the generators.