高度图噪声地形
experimental
TIP
本教程假设您已对Molang语言、特性(feature)及特性规则(feature rule)有基本了解。
本教程将展示如何利用q.noise这个Molang查询来创建基于噪声的地形。
单方块特性
首先定义基础方块特性。这里我们以石头为例:
BP/features/stone_feature.json
json
{
"format_version": "1.13.0",
"minecraft:single_block_feature": {
"description": {
"identifier": "wiki:stone_feature"
},
"places_block": "minecraft:stone",
"enforce_survivability_rules": false,
"enforce_placement_rules": false
}
}散布特性
这是用于生成地形的核心特性:
BP/features/column.json
json
{
"format_version": "1.13.0",
"minecraft:scatter_feature": {
"description": {
"identifier": "wiki:column"
},
"iterations": "t.height=64+(q.noise(v.originz/64,v.originx/64))*16; return t.height;",
"places_feature": "wiki:stone_feature",
"x": 0,
"z": 0,
"y": {
"extent": [-64, "t.height"],
"distribution": "fixed_grid"
}
}
}关于iterations参数的解析:
- 我们定义了临时变量
t.height来存储噪声函数结果 - 初始值64是地形基准高度
q.noise查询会返回-1到1之间的柏林噪声值,坐标除以64用于平滑噪声- 乘以16用于控制地形起伏幅度
最终效果是从-64到动态高度的垂直石柱群。由于使用柏林噪声,相邻石柱的高度会呈现渐变效果(如64,65,66,68,69,68...),而非完全随机分布。
特性规则
BP/feature_rules/column_grid_placement.json
json
{
"format_version": "1.13.0",
"minecraft:feature_rules": {
"description": {
"identifier": "wiki:column_grid_placement",
"places_feature": "wiki:column"
},
"conditions": {
"placement_pass": "first_pass",
"minecraft:biome_filter": {
"any_of": [
{
"test": "has_biome_tag",
"value": "overworld"
},
{
"test": "has_biome_tag",
"value": "overworld_generation"
}
]
}
},
"distribution": {
"iterations": 256,
"x": {
"extent": [0, 15],
"distribution": "fixed_grid"
},
"y": 0,
"z": {
"extent": [0, 15],
"distribution": "fixed_grid"
}
}
}
}设置256次迭代(16x16区块面积)确保整区块生成。现在您已创建出基于噪声的自定义地形!可以自由调整参数进行实验。

