68 lines
1.7 KiB
Markdown
68 lines
1.7 KiB
Markdown
---
|
||
front:
|
||
hard: 入门
|
||
time: 分钟
|
||
---
|
||
|
||
# 自定义红石方块
|
||
|
||
自定义红石方块是一种特殊的自定义方块,包括信号源方块与红石机械元件方块,支持方块相关的所有事件以及接口。
|
||
|
||
|
||
|
||
## 自定义红石信号源方块
|
||
|
||
自定义红石信号源方块放置在地图上会发出红石信号,信号的初始值可以配置。
|
||
|
||
其中type为producer,strength为初始红石信号量。
|
||
|
||
```json
|
||
{
|
||
"format_version": "1.10.0",
|
||
"minecraft:block": {
|
||
"description": {
|
||
"identifier": "customblocks:customblocks_redstone",
|
||
"register_to_creative_menu": true,
|
||
"is_experimental": false,
|
||
},
|
||
"components": {
|
||
"minecraft:map_color": {
|
||
"color": "#408080"
|
||
},
|
||
"netease:redstone": {
|
||
"type": "producer",
|
||
"strength": 10
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
|
||
## 自定义红石机械元件方块
|
||
|
||
自定义红石机械元件方块放置在地图上会接收红石信号,可以被激活。
|
||
|
||
对于自定义红石机械元件方块,其红石信号变化时触发事件<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockstrengthchangedserverevent" rel="noopenner"> BlockStrengthChangedServerEvent </a>。
|
||
|
||
其中type为consumer,初始红石信号量为0(未激活状态),不能通过netease:redstone的strength字段进行配置。
|
||
|
||
```json
|
||
{
|
||
"format_version": "1.10.0",
|
||
"minecraft:block": {
|
||
"description": {
|
||
"identifier": "customblocks:customblocks_redstone_consumer",
|
||
"register_to_creative_menu": true,
|
||
"is_experimental": false,
|
||
},
|
||
"components": {
|
||
"netease:redstone": {
|
||
"type": "consumer"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|