附加包教程:27.地物
本帖最后由 Cat_Anchor 于 2023-6-17 16:39 编辑前言
现在我们来讲讲地物。常用的地物有好几种,分别是:结构模板地物、矿石地物、单方块地物、分散地物、树地物和晶洞地物。
https://klpbbs.com/static/image/hrline/line5.png
地物
打开行为包根目录,打开features文件夹,这里用于存储地物。但是只有这个文件夹是不能生成任何地物的,因为这个地物没有生成规则。打开feature_rules文件夹,这里用于存储地物规则。
注意,所有地物和地物规则的ID必须和文件名匹配。比如地物ID是supplementary:chorus_tree1,那么文件名必须是chorus_tree1.json。
地物是一个比较难、类型很多的东西,但很多种地物只适用于一种或少量种情况。比如悬挂植物地物,几乎只能用来放置洞穴藤蔓和垂泪藤。又比如雕刻洞穴地物,只能用来放置下界的洞穴。所以,我在此只会细说我刚才列出的那些地物类型。
除此之外,我会在讲完地物之后讲地物规则。
结构模板地物
{
"format_version": "1.16.0",
"minecraft:structure_template_feature": {
"description": {
"identifier": "supplementary:chorus_tree1" //地物ID
},
"structure_name": "mystructure:chorus_tree_1", //要放置的结构的名称,这就是我让你记住你导出的结构的名字的原因。
"facing_direction": "random", //方向
"adjustment_radius": 0, //“调整半径”,写0即可,官方文档上没有介绍。
"constraints": {
"grounded": {} //可以决定结构是着地的还是浮空的,把"grounded": {}换成"unburied": {},"block_intersection": {"block_allowlist": ["minecraft:air"]}可以让结构浮空。
}
}
}
矿石地物
{
"format_version": "1.13.0",
"minecraft:ore_feature": {
"description": {
"identifier": "example:malachite_ore_feature" //地物ID
},
"count": 12, //要放置的矿石的最大数量。(其实要放的方块不是矿石也行)
"replace_rules": [
{
"places_block": "example:malachite_ore", //要放置的方块,下同
"may_replace": [
"minecraft:stone" //要替换的方块,下同
]
},
{
"places_block": "example:granite_malachite_ore",
"may_replace": [
"minecraft:granite"
]
},
{
"places_block": "example:andesite_malachite_ore",
"may_replace": [
"minecraft:andesite"
]
}
]
}
}
树地物
{
"format_version": "1.13.0",
"minecraft:tree_feature": {
"description": {
"identifier": "supplementary:tree_v_birch_x_birch_tree" //地物ID
},
"trunk": { //树干部分
"trunk_height": { //树干高度
"range_min": 7, //最小是7
"range_max": 10 //最大是10
},
"trunk_block": {
"name": "minecraft:log", //树干方块,这里是白桦木
"states": {
"old_log_type": "birch" //指定是白桦木
}
}
},
"canopy": { //树冠部分
"canopy_offset": { //树冠的偏移量
"min": -3, //最小偏移-3
"max": 0 //最大偏移0
},
"variation_chance": [//变种机会,应该是指树叶的形状
{ //这个对象代表了一个分数,下同
"numerator": 1, //分子
"denominator": 2 //分母
},
{
"numerator": 1,
"denominator": 2
},
{
"numerator": 1,
"denominator": 2
},
{
"numerator": 1,
"denominator": 1
}
],
"leaf_block": {
"name": "minecraft:leaves", //树叶方块,这里是桦树叶
"states": {
"old_leaf_type": "birch"
}
}
},
"base_block": [ //指定底部的方块
"minecraft:dirt", //泥土
{
"name": "minecraft:dirt",
"states": {
"dirt_type": "coarse" //砂土
}
}
],
"may_grow_on": [ //指定能长在……方块上
"minecraft:dirt", //泥土
"minecraft:grass", //草方块
"minecraft:podzol", //灰化土
{
"name": "minecraft:dirt",
"states": {
"dirt_type": "coarse" //砂土
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 0 //干的耕地,moisturized_amount代表耕地湿润程度,0-7的值,7是湿润的
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 1
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 2
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 3
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 4
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 5
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 6
}
},
{
"name": "minecraft:farmland",
"states": {
"moisturized_amount": 7
}
}
],
"may_replace": [ //树长成时会替换……方块
"minecraft:air", //空气
{
"name": "minecraft:leaves",
"states": {
"old_leaf_type": "oak" //橡树叶
}
},
{
"name": "minecraft:leaves",
"states": {
"old_leaf_type": "spruce" //云杉树叶
}
},
{
"name": "minecraft:leaves",
"states": {
"old_leaf_type": "birch" //桦树叶
}
},
{
"name": "minecraft:leaves",
"states": {
"old_leaf_type": "jungle" //丛林树叶
}
},
{
"name": "minecraft:leaves2",
"states": {
"new_leaf_type": "acacia" //金合欢树叶
}
},
{
"name": "minecraft:leaves2",
"states": {
"new_leaf_type": "dark_oak" //深色橡树叶
}
}
],
"may_grow_through": [ //可以穿过……方块长成树
"minecraft:dirt", //泥土
"minecraft:grass", //草方块
{
"name": "minecraft:dirt",
"states": {
"dirt_type": "coarse" //砂土
}
}
]
}
}
单方块地物
{
"format_version": 1.13.0,
"minecraft:single_block_feature": {
"description": {
"identifier": "example:single_pumpkin_feature" //地物ID
},
"places_block": "example:pumpkin", //要放的方块。没错,这个地物就是在世界里放个方块,经常用于放小花小草之类的。
"enforce_placement_rules": true,
"enforce_survivability_rules": true,
"may_place_on": [
"example:grass" //会放在哪些方块上
],
"may_replace": [
"example:air" //会替换哪些方块
]
}
}
晶洞地物
{
"format_version": "1.13.0",
"minecraft:geode_feature": {
"description": {
"identifier": "minecraft:diamond_geode_feature" //地物ID
},
"filler": "minecraft:air", //晶洞里面的方块,一般是空气
"inner_layer": "minecraft:diamond_block", //内层方块,像是紫水晶方块
"alternate_inner_layer": "minecraft:emerald_block", //内层方块,像是紫水晶母岩方块
"middle_layer": "minecraft:calcite", //中间层,像是方解石
"outer_layer": "minecraft:obsidian", //外层,像是平滑玄武岩
"inner_placements": [
{
"name": "minecraft:amethyst_cluster", //要放在紫水晶母岩上面的方块
"states": {
"amethyst_cluster_type": "small"
}
}
],
"min_outer_wall_distance": 4,
"max_outer_wall_distance": 7,
"min_distribution_points": 3,
"max_distribution_points": 5,
"min_point_offset": 1,
"max_point_offset": 3,
"max_radius": 16, //最大半径
"crack_point_offset": 2.0,
"generate_crack_chance": 0.95, //裂开一个口子的几率,这里是95%
"base_crack_size": 2.0,
"noise_multiplier": 0.025,
"use_potential_placements_chance": 0.35,
"use_alternate_layer0_chance": 0.083,
"placements_require_layer0_alternate": true,
"invalid_blocks_threshold": 1
}
}
分散地物
这个地物是与其他地物一起使用的。
{
"format_version": 1.13.0,
"minecraft:scatter_feature": {
"description": {
"identifier": "example:scatter_flowers_feature" //地物ID
},
"places_feature": "example:flower_feature", //要分散的地物ID
"iterations": 10, //地物的数量。
"x": {
"distribution": "uniform",
"extent": [ 0, 15 ] //范围,这里是0-15
},
"y": 64,
"z": {
"distribution": "uniform",
"extent": [ 0, 15 ] //范围,这里是0-15
}
}
}
地物规则
{
"format_version": "1.13.0",
"minecraft:feature_rules": {
"description": {
"identifier": "supplementary:end_ruin_feature_rule", //地物规则的ID
"places_feature": "supplementary:end_ruin_feature" //这个地物规则管的地物ID
},
"conditions": {
"placement_pass": "first_pass",
"minecraft:biome_filter": [ //生物群系测试,只有在条件成立时才放置地物
{
"all_of": [ //其中所有成立才成立
{
"any_of": [ //其中任何一个成立就成立
{
"test": "has_biome_tag",
"operator": "==",
"value": "the_end" //末地
}
]
}
]
}
]
},
"distribution": {
"iterations": 1, //地物个数
"x": {
"distribution": "uniform",
"extent": [ //区块内的范围,0-16
0,
16
]
},
"y": {
"distribution": "uniform",
"extent": [ //区块内的范围,45-75
45,
75
]
},
"z": {
"distribution": "uniform",
"extent": [ //区块内的范围,0-16
0,
16
]
}
}
}
}
这就是关于常用地物的讲解了。还有超级多的地物类型,可以通过官方发布的文档查看。有一点不便的是,官方的文档是英文的,还需要翻译一下才能看懂。(有时候翻译了也看不懂)
https://klpbbs.com/static/image/hrline/line1.png
总结
这一期,我们学完了地物。下一期,我们就要讲交易了。
第二十六期 第二十七期 第二十八期 感谢分享 很细致的教程,但是我有个问题想请教:分散地物是什么[贴吧_滑稽] Baka_Bee 发表于 2023-3-5 12:44
很细致的教程,但是我有个问题想请教:分散地物是什么
我个人理解是起到类似于地物规则的效果,比如一个地物固定在区块0,0位置生成,那分散地物(Scatter Feature)的作用就是让它在区块内随机位置生成,或者使用q.noise根据柏林噪声依据地形进行生成
页: [1]