世界生成 API
基本信息
| 属性 | 值 |
|---|---|
| 生成器接口 | com.cardinalstar.cubicchunks.api.worldgen.IWorldGenerator |
| 装饰器接口 | api/worldgen/decoration/IWorldDecorator |
| 地形生成器接口 | api/worldgen/decoration/ICubeGenerator |
| 群系填充器接口 | api/worldgen/decoration/ICubePopulator |
| 注册表接口 | api/worldgen/WorldgenRegistry |
| 依赖图 | api/registry/IDependencyGraph<out IRegistryEntry> |
| 标准实现 | api/worldgen/impl/StandardWorldDecorator |
| 内建实例 | BuiltinWorldDecorators.VANILLA、CUBIC_VANILLA |
功能
其它模组通过装饰器 + 依赖图模型接入立方世界生成。
StandardWorldDecorator(api/worldgen/impl/StandardWorldDecorator.java:14)同时实现 WorldgenRegistry 与 IWorldDecorator,并把生成拆为两个依赖图与四个阶段:
| 成员 | 签名 | 行 |
|---|---|---|
| 地形图 | terrain() → IDependencyGraph<ICubeGenerator> |
:21 |
| 群系图 | population() → IDependencyGraph<ICubePopulator> |
:26 |
| 预生成 | pregenerate(World, CubePos) |
:31 |
| 生成 | generate(World, Cube) |
:38 |
| 预填充 | prepopulate(World, CubePos) |
:45 |
| 填充 | populate(World, Cube) |
:52 |
依赖图本身由 api/registry/ 提供:IDependencyGraph、IRegistryEntry、AbstractRegistryEntry、Registry。注册时可用 addObject(name, impl, ...) 添加实现,或用 addTarget(name) 声明一个被依赖的目标组——CubicChunks 自己的用法就是后者(WorldGenerators.java:39-40 声明 caves-all)。
IWorldGenerator(api/worldgen/IWorldGenerator.java:38)是单个世界的生成器契约,方法包括 populate(Cube)(:69)、recreateStructures(ICube)(:79)、recreateStructures(Chunk)(:89)。另有 api/worldgen/GenerationResult.java 表示生成结果,api/worldgen/IWorldGenerator.java 与 api/worldgen/structure/feature/ICubicFeatureStart.java 分别覆盖特征起点。
本移植未移植上游的 CubeGeneratorsRegistry / CubePopulatorRegistry:这两个类在源码树中不存在(grep -rn 'CubeGeneratorsRegistry\|CubePopulatorRegistry' src/main --include='*.java' 仅命中 world/worldgen/WorldGenerators.java:46 与 :50 两行注释)。
数值
| 数值名 | 值 | 来源 |
|---|---|---|
| 装饰器生成阶段数 | 4(pregenerate/generate/prepopulate/populate) | StandardWorldDecorator.java:31,38,45,52 |
| 依赖图数量 | 2(terrain / population) | StandardWorldDecorator.java:21,26 |
| 内建装饰器数量 | 2(VANILLA、CUBIC_VANILLA) |
api/worldgen/BuiltinWorldDecorators.java:27-28 |
| 本模组实际注册的地形目标组 | 1(caves-all) |
WorldGenerators.java:40 |
| 本模组实际注册的群系填充器 | 1(low-deepslate,需 EFR) |
WorldGenerators.java:62 |
交互
| 触发 | 行为 |
|---|---|
| 模组 preInit | WorldGenerators.init() 填充 CUBIC_VANILLA 的内容 |
| 生成一个立方体 | 装饰器依次执行 pregenerate → generate → prepopulate → populate |
其它模组实现 ICubeGenerator |
通过 terrain() 依赖图挂入生成流程 |
其它模组实现 ICubePopulator |
通过 population() 依赖图挂入群系填充 |
| 装 Et Futurum Requiem | 多出 low-deepslate 深板岩填充器 |
相关条目
- Cubic Vanilla 装饰器 - 本模组自身的注册示例
- 洞穴生成器 - 已实现但未注册的
ICubeGenerator - 立方区块 API - 生成结果涉及的
ICube等类型