# 练习1:水鸭浮在水上时的泡泡粒子
# 作者:境界
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
"identifier": "design:green_head_duck",
"render_controllers": [
"controller.render.default"
],
"textures": {
"default": "textures/entity/green_head_duck"
},
"geometry": {
"default": "geometry.green_head_duck"
},
"materials": {
"default": "entity_alphatest"
},
"animations": {
"move": "animation.chicken.move",
"look_at_target": "animation.common.look_at_target"
},
"scripts": {
"animate": [
{ "move": "query.modified_move_speed" },
"look_at_target"
]
},
"spawn_egg": {
"base_color": "#256143",
"overlay_color": "#dd9238"
}
}
}
}
使用前面的知识,我们知道今天要播放粒子,首先要把粒子资源加载在生物定义文件中。
1)在description内新增particle_effects,引用原版粒子"minecraft:basic_bubble_particle_manual",同时将粒子短名称写为bubble。
2)在动画控制器文件夹内新增一个控制绿头水鸭播放粒子的动画控制器,由于我们希望水鸭不停播放这个粒子,因此只需定义一个状态即可。
3)将动画控制器加载到生物定义文件的动画资源键中,接着在scripts/animate中的根动画加载这个动画控制器。
4)该粒子的设定下,释放的特效只会在水中有效,因此在游戏内,可以看到只有绿头水鸭在水里才会冒出泡泡粒子。
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.green_head_duck.particle": {
"initial_state": "default",
"states": {
"default": {
"particle_effects": [
{
"effect": "bubble"
}
]
}
}
}
}
}
{
"format_version": "1.10.0",
"minecraft:client_entity": {
"description": {
"identifier": "design:green_head_duck",
"render_controllers": [
"controller.render.default"
],
"textures": {
"default": "textures/entity/green_head_duck"
},
"geometry": {
"default": "geometry.green_head_duck"
},
"materials": {
"default": "entity_alphatest"
},
"particle_effects": {
"bubble": "minecraft:basic_bubble_particle_manual"
},
"animations": {
"move": "animation.chicken.move",
"look_at_target": "animation.common.look_at_target",
"particle": "controller.animation.green_head_duck.particle"
},
"scripts": {
"animate": [
{ "move": "query.modified_move_speed" },
"particle",
"look_at_target"
]
},
"spawn_egg": {
"base_color": "#256143",
"overlay_color": "#dd9238"
}
}
}
}
现在,一个在水中移动会不停冒水泡泡的绿头水鸭就做好了。