Files
netease-modsdk-wiki/docs/mconline/10-addon教程/第09章:自定义方块/课程04.简易教学①-制作会发光的地灯.md
2025-03-17 13:24:39 +08:00

101 lines
2.3 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/4_1.fd4b17c4.jpg
hard: 进阶
time: 15分钟
---
# 简易教学①:制作会发光的地灯
#### 作者:境界
#### 自定义方块行为包
```
{
"format_version": "1.16.0",
"minecraft:block": {
"description": {
"identifier": "design:lamp",
"register_to_creative_menu": true
},
"components": {
"minecraft:block_light_absorption": 0,
"netease:tier": {
"digger": "pickaxe",
"level": 0
},
"netease:render_layer": {
"value": "alpha"
},
"minecraft:block_light_emission": 1.0,
"minecraft:destroy_time": 2.0,
"minecraft:map_color": "#ffffff"
}
}
}
```
11.16.0是当前下界更新的自定义方块内容格式所以我们在format_version里填1.16.0
2identifier是自定义方块的名称域这里可以由开发者自己定义。register_to_creative_menu是管理方块是否注册到创造背包里。
3components下的参数会储存方块的各项功能。
-将透光度调为0减少环境光的影响。
-将该方块设置为被木镐以上等级的镐子挖掘有速度加成。
-由于使用了带有透明图层的贴图,将该方块的渲染材质设置为透明。
-将发光度设置为1.0,即发最强的光。
-将方块破摔时间设置为2.0
-自定义方块在地图上显示的颜色,这里可以由开发者自己定义。
![](./images/4_1.jpg)
#### 自定义方块资源包
1在resourcepack/blocks.json中添加该方块的名称域与模型资源名称名称来自resourcepack/models/netease_block/内的模型文件里的名称域。将走在方块上和破坏方块的音效设置为玻璃音效。
```
{
"format_version": [
1,
1,
0
],
"design:lamp": {
"netease_model": "design:lamp",
"sound": "glass"
}
}
{
"format_version": "1.13.0",
"netease:block_geometry": {
"bones": [
],
"description": {
"identifier": "design:lamp",
"textures": [
"design:lamp"
],
"use_ao": false
}
}
}
```
#### 实际游戏效果
![](./images/4_2.jpg)