Files
netease-modsdk-wiki/docs/mconline/10-addon教程/第07章:自定义生物/课程15.练习1-水鸭浮在水上时的泡泡粒子.md
2025-03-17 13:24:39 +08:00

134 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
front: https://mc.res.netease.com/pc/zt/20201109161633/mc-dev/assets/img/15_1.379b8dfc.jpg
hard: 进阶
time: 15分钟
---
# 练习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"
}
}
}
}
```
现在,一个在水中移动会不停冒水泡泡的绿头水鸭就做好了。
![](./images/15_1.jpg)