世界生成
基本信息
| 属性 | 值 |
|---|---|
| 装饰器 | BiomeDecoratorHardcoreEnd extends BiomeEndDecorator(63 行) |
| 6 个 WorldGen 特性 | WorldGenObsidianSpike / WorldGenBlob / WorldGenEnergyCluster / WorldGenEndiumOre / WorldGenMeteoroid / WorldGenEndPowderOre |
| 调用点 | BiomeGenHardcoreEnd.createBiomeDecorator()(world/biome/BiomeGenHardcoreEnd.java:62-64) |
| 触发时机 | ChunkProviderHardcoreEnd.populate() 调 ((BiomeGenHardcoreEnd) BiomeGenBase.sky).decorate(...)(world/ChunkProviderHardcoreEnd.java:80) |
| 源码自带规格表 | world/biome/BiomeDecoratorHardcoreEnd.java:21-36(块注释) |
功能
genDecorations(BiomeGenBase biome) 只在维度 ID 为 1(末地)时执行本模组逻辑,否则回退 super.genDecorations(biome)(BiomeDecoratorHardcoreEnd.java:56-60)。距离基准 distFromCenter = distance(chunk_X >> 4, chunk_Z >> 4) × 16D(:64),即区块到末地原点的方块距离。
源码块注释(:21-36)自带一份完整的生成层规格表,把「constant / linear± / cubic±」与具体区间都列了出来,可与下方代码逐条对照。
源码自带规格表(BiomeDecoratorHardcoreEnd.java:29-35 原文转录)
| 元素 | 曲线类型 | 区间 | 附加条件 |
|---|---|---|---|
| Dragon Lair | single | 0–120 | — |
| End Powder Ore | constant | 0– | — |
| Endstone Blob | constant | 100– | 部分类型生成得更远 |
| Energy Cluster | cubic+ | 320–6400 | x != 0 => x*0.45+0.12 |
| Energy Cluster (2) | linear+ | 320–6400 | x != 0 => x*0.8+0.1 |
| Dungeon Tower | cubic− | 350 / 900–3800 | x != 0 => x*0.75+0.25 |
| Endium Ore | cubic+ | 500–12000 | x != 0 => x*0.6+0.34 |
| Endium Ore (2) | linear+ | 1500–21000 | 控制生成方块最大数量 |
| Meteoroid | linear+− | 1280–2700–15000 | — |
| Biome Island | linear+ | 1600–4000 | x != 0 => x*0.35+0.65 |
| Insidious Sanctuary | linear+− | 3200–8500–36000 | x != 0 => x*0.8+0.2;4200 起步,高概率时边界更低 |
⚠️ 规格表最后一行
Insidious Sanctuary对应的代码在本文件中不存在 ——world/structure/sanctuary/整棵子树未注册(见结构)。这属于未完成功能,仓库有// TODO SANCTUARY注释作为 intent evidence,不是文档与实现不一致的缺陷。
数值
逐生成器代码参数
| 元素 | 距离门槛 | 概率 | 数量 / 高度 | 位置 |
|---|---|---|---|---|
WorldGenObsidianSpike |
dist < 120 |
rand.nextInt(5) == 0(0.2) |
高度 = 地表实心方块顶 | :66-71 |
WorldGenBlob |
dist > 102 |
abs(nextGaussian()) < 0.285 |
y = 32 + rand(60) |
:73-77 |
WorldGenEnergyCluster |
dist > 320 |
0.12 + 0.45 × cubic2Incr(dist, 320, 6400) 且 nextDouble()² > 0.65 |
循环 rand(4) 次,每次后以 0.1 + 0.8 × linear2Incr(dist, 320, 6400) 决定是否继续 |
:79-91 |
WorldGenEndiumOre |
dist > 500 |
0.34 + 0.6 × cubic2Incr(dist, 500, 12000) |
尝试上限 440 次;目标数 max = 1 + rand(1 + rand(2 + ceil(9 × linear2Incr(dist, 1500, 21000))));y = 10 + rand(100) |
:93-106 |
WorldGenMeteoroid |
dist > 1280 |
linear3IncrDecr(dist, 1280, 2700, 15000) 且 nextFloat()² > 0.666 |
rand(3) 次;y = 8 + rand(112) |
:108-115 |
WorldGenEndPowderOre |
无距离门槛 | 无概率门槛 | 尝试上限 22 次,目标 4 + rand(5) 个;y = 35 + rand(92) |
:117-123 |
randX() / randZ() 返回 chunk_X + rand(16) + 8(:140-146)—— 采样点落在区块中央,避免边缘。
末影龙初始生成(:125-129)
if (chunk_X == 0 && chunk_Z == 0) {
EntityBossDragon dragon = new EntityBossDragon(currentWorld);
dragon.setLocationAndAngles(0D, 128D, 0D, randomGenerator.nextFloat() * 360F, 0F);
currentWorld.spawnEntityInWorld(dragon);
}
末影龙固定生成在 (0, 128, 0),朝向随机。这解释了块注释中「Dragon Lair | single | 0-120」的 120 —— 对应 WorldGenObsidianSpike 的距离门槛。
generateOres() 覆写(:132-138)
原版 BiomeEndDecorator.generateOres() 被完全替换:仅在 overrideWorldGen 为 false 时广播 OreGenEvent.Pre / OreGenEvent.Post(:135-136),不生成任何原版末地矿脉。开启 overrideWorldGen 时连事件都不发,彻底屏蔽其他 mod 的末地矿石。
交互
错误处理(:152-165)
tryGenerate 捕获 RuntimeException 后记录警告并返回 false,不吞异常:
} catch (RuntimeException e) {
Log.warn("Failed generating " + generator.getClass().getSimpleName() + " at " + (chunk_X + x) + ","
+ (chunk_Z + z) + ", there might be an empty chunk.");
return false;
}
注意 catch 块内没有记录 e(异常本体)—— 只有一句推测性文本。仓库无测试、无注释、无 commit 提及这一取舍,故此处仅记录事实。
性能计时
6 个生成器都用 Stopwatch.timeAverage(name, sampleSize) / Stopwatch.finish(name) 包裹,采样数分别为 4(Spike)与 64(其余 5 个),便于在 debug 模式(logDebuggingInfo)下观察开销。
未注册内容
world/feature/ 下 6 个 WorldGen* 类全部活注册(BiomeDecoratorHardcoreEnd.java:47-52 全部实例化)。world/feature/blobs/ 子包(BlobGeneratorChain / BlobGeneratorFromCenter / BlobGeneratorRecursive / BlobGeneratorSingle / BlobGeneratorSingleCut 共 5 个生成器 + blobs/populators/ 11 个填充器)是 WorldGenBlob 的内部实现,被间接使用。