feat:上传mcguide-开发指南部份

This commit is contained in:
Othniel su
2024-12-23 10:57:59 +08:00
parent 7292166c88
commit 0dc59fa4f0
3297 changed files with 63375 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
---
front:
hard: 入门
time: 分钟
---
# 特殊方块概述
开发者可通过在方块定义json中添加base_block来修改方块的基础行为。
base_block包括
* mob_spawner 自定义刷怪箱
* portal 自定义传送门
* custom_crop_block 自定义农作物
* custom_heavy_block 自定义重力方块
* liquid 自定义静态流体方块
* flowing_liquid 自定义动态流体方块
![special-1](.././picture/customblock/special-1.png)
如下图为自定义刷怪箱的base_block配置
![special-2](.././picture/customblock/special-2.png)

View File

@@ -0,0 +1,27 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义刷怪箱
## base_block设置
- **自定义刷怪箱方块的base_block需要设为mob_spawner**
- **还应在blocks.json中进行如下设置**
![special-3](.././picture/customblock/special-3.png)
## netease:mob_spawner
可在netease:mob_spawner组件中设置刷怪的类型目前支持原生生物、微软自定义生物。
| 键 | 类型 | 默认值 | 解释 |
| ---- | ------ | ------ | -------------------------------- |
| type | string | | 必须设置,用于控制生成的生物类型 |
- 原生生物type为"minecraft:Namespaced ID",如"minecraft:parrot"Namespaced ID可参考[官方wiki](https://minecraft.gamepedia.com/Mob#List_of_mobs)中各Mob的详细信息。
- 微软自定义生物type为"minecraft:entity"中"description"的"identifier"项,可参考[自定义生物文档](../../3-自定义生物/01-自定义基础生物.md)及[CustomBlocksMod](../../../13-模组SDK编程/60-Demo示例.md#CustomBlocksMod)中的customblocks_test_mobspawner1.json。

View File

@@ -0,0 +1,81 @@
---
hard: 入门
time: 分钟
---
# 自定义工作台
## 概述
自定义工作台组件支持将一个方块改造成一个指定配方的自定义工作台。
需设置以下组件
## netease:block_crafting_table
可在netease:block_crafting_table组件中为工作台命名并指定允许在这个工作台使用的配方
| 键 | 类型 | 默认值 | 解释 |
| ------------------ | ------ | ------ | ------------------------------------------------------------ |
| custom_description | string | | 可选不填为自定义方块的identifier。pocket模式下存在字数限制限制为9个中文字符。 |
| crafting_tags | list | | 必填用于该自定义工作台的配方的tag不填无法打开工作台原版工作台的tag是crafting_table |
### 示例
```json
//自定义工作台方块的json,相关内容都在component里面添加
{
"format_version": "1.16.100",
"minecraft:block": {
"description": {
"identifier": "customblocks:customblocks_test_mobspawner1",
"register_to_creative_menu": true
},
"components": {
"netease:block_crafting_table": {
"custom_description": "你好呀,我的自定义工作台",
"crafting_tags": [
"customTag"
]
}
}
}
}
```
效果如下图
![image-20230330215418831](../picture/customblock/customCraftingTable.png)
```json
//自定义配方例子其中的tags对应上文工作台中的crafting_tags
{
"format_version": "1.12",
"minecraft:recipe_shaped": {
"description": {
"identifier": "customblocks:customblocks_model_flower"
},
"tags": ["customTag"],
"pattern": [
"X",
"#"
],
"key": {
"#": {
"item": "customblocks:customblocks_test0"
},
"X": {
"item": "minecraft:dirt"
}
},
"result": {
"item": "customblocks:customblocks_model_flower"
}
}
}
```
## 注意
目前国际版也有一套自定义工作台,两者是冲突的,网易版自定义工作台会覆盖微软版的自定义工作台,请勿一起使用

View File

@@ -0,0 +1,65 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义传送门方块
## base_block设置
- **自定义传送门方块的base_block需要设为portal。**
## 动画纹理
- 可通过在`resource/textures/flipbook_textures.json`中配置动画纹理使其贴图拥有动态效果,属于微软功能。
## 传送门方块介绍
- 传送门方块拥有两种朝向其方块延伸方向分别与X轴、Z轴相同如图所示
- 可在netease:portal中设置传送门方块上播放的粒子特效以及目标维度
![special-4](.././picture/customblock/special-4.png)
## netease:portal
| 键 | 类型 | 默认值 | 解释 |
| -------------------- | ------ | ------ | ------------------------------------------------------------ |
| particle_east_west | string | | 可选对应于粒子json文件中的identifier用于控制方块与Z轴同向时播放的粒子特效 |
| particle_north_south | string | | 可选对应于粒子json文件中的identifier用于控制方块与X轴同向时播放的粒子特效 |
| target_dimension | int | | 必须设置,用于控制进入传送门方块后到达的目标维度 |
- 粒子特效应放置于`resource/particles`,粒子特效编写可参考[官方关于粒子组件的说明](https://minecraft.gamepedia.com/Bedrock_Edition_particle_documentation)。
- **目标维度为0或3-20的整数或者大于21的新版自定义维度的数值1下界和2末地会被视作0来处理。**
## 自定义传送门方块相关特性
- 若通过服务端blockInfo组件的SetBlockNew接口放置传送门方块
- 附加值'aux'设为1时该方块延伸方向与X轴相同播放particle_north_south对应的粒子
- 附加值'aux'设为2时该方块延伸方向与Z轴相同播放particle_east_west对应的粒子。
- **避免将附加值'aux'设为0。**
- 还可以在游戏内通过指令/setblock放置方块**注意'aux'值应设为1或2。**
如下为在(0, 65, 0)处放置aux值为2的customblocks_test_portal_blue方块的指令
`/setblock 0 65 0 customblocks_test_portal_blue 2`
- 手动放置的传送门方块附加值'aux'始终为0无论它朝向哪里**不建议开发者手动放置传送门方块。**
- 目标维度与当前维度相同时,将不会进行传送。
- 只有玩家才能够通过自定义传送门方块进行传送。
- 同一玩家存在一定的传送冷却时间,不会连续传送。
- 传送前后玩家坐标不发生改变。

View File

@@ -0,0 +1,411 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义农作物
## 概述
开发者可以通过以下两种方式实现自定义农作物详见demo [CustomCropMod](../../../13-模组SDK编程/60-Demo示例.md#CustomCropMod)
1通过[netease:transform组件](#netease_transform)定义农作物之间的转换规则;
2通过python脚本监听<a href="../../../../../mcdocs/1-ModAPI/事件/物品.html#serveritemuseonevent" rel="noopenner"> ServerItemUseOnEvent </a>、<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockrandomtickserverevent" rel="noopenner"> BlockRandomTickServerEvent </a>、<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockneighborchangedserverevent" rel="noopenner"> BlockNeighborChangedServerEvent </a>等事件控制方式。
## 公共组件说明
### base_block设置
- **自定义农作物方块的base_block需要设为custom_crop_block**
<span id="netease_transform"></span>
### netease:transform
该组件用于自定义农作物方块之间的转换
| 键 | 类型 | 默认值 | 解释 |
| ---------- | ---- | ------ | ---------------------------------------------------------- |
| conditions | dict | | 农作物方块转换的条件三个条件同时满足时会转化为result方块 |
| result | str | | 农作物方块转换后的方块名称 |
例如:
```json
"netease:transform": {
"conditions": {
"brightness": { # 农作物生长必须满足的光照条件
"max": 15,
"min": 9
},
"random_tick_count": { # 转化需要经过的随机tick次数
"value": 2 # 2表示在第三次随机tick时转化不允许小于等于0的值
},
"surrouding": { # 转化需要的周围方块
"value": "minecraft:sand",
"radius": 1 # 半径
}
},
"result": "minecraft:egg" # 转化为哪种方块
}
```
### minecraft:seed
自定义种子,详见[minecraft:seed](../../1-自定义物品/1-自定义基础物品.md#minecraft_seed)
## 自定义农作物方式一
该方式适用于纯配置json不需要写任何python脚本逻辑。
这种方式包括一个种子(自定义物品)与三种自定义农作物的状态(自定义方块)。
### 1自定义种子
参照[自定义基础物品](../../1-自定义物品/1-自定义基础物品.md)自定义一个农作物种子customcrop:custom_wheat_seeds。
```json
{
"format_version": "1.10",
"minecraft:item": {
"description": {
"identifier": "customcrop:custom_wheat_seeds",
"register_to_create_menu":true,
"category": "Nature"
},
"components": {
"minecraft:seed": {
"crop_result": "customcrop:customcrop_stage0",# 种子生成的方块
"plant_at": "minecraft:sand" #种植条件
}
}
}
}
```
json说明
该种子的标识为customcrop:custom_wheat_seeds它包含一个minecraft:seed组件其中
| 字段 | 值 | 说明 |
| ----------- | ---------------------------- | ------------------------------------------------------------ |
| crop_result | customcrop:customcrop_stage0 | 种子将生长为customcrop:customcrop_stage0自定义方块 |
| plant_at | minecraft:sand | 该种子只能在“沙子”上种植,种植后其所有的生长状态的下方方块也必须为“沙子”,如果底部的方块被破坏,农作物也将被破坏 |
### 2自定义三种农作物状态
参照[自定义方块](../0-自定义方块概述.md)我们将自定义三种农作物状态分别为customcrop:customcrop_stage0、customcrop:customcrop_stage1、customcrop:customcrop_stage2其中部分json如下所示
#### customcrop:customcrop_stage0
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_stage0",
"register_to_creative_menu": true,
"is_experimental": false,
"base_block": "custom_crop_block"
},
"components": {
...
"netease:transform": {
"conditions": {
"brightness": { # 光照条件
"max": 15,
"min": 9
},
"random_tick_count": { # 随机tick次数条件
"value": 1
},
"surrouding": { # 在半径为1的周围需要存在“沙子”
"value": "minecraft:sand",
"radius": 1
}
},
"result": "customcrop:customcrop_stage1" # 成长下一阶段的方块
},
...
}
}
}
```
#### customcrop:customcrop_stage1
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_stage1",
"register_to_creative_menu": true,
"is_experimental": false,
"base_block": "custom_crop_block"
},
"components": {
...
"netease:transform": {
"conditions": {
"brightness": {
"max": 15,
"min": 9
},
"random_tick_count": {
"value": 1
},
"surrouding": {
"value": "minecraft:sand",
"radius": 1
}
},
"result": "customcrop:customcrop_stage2" # 成长下一阶段的方块
},
...
}
}
}
```
#### customcrop:customcrop_stage2
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_stage2",
"register_to_creative_menu": true,
"is_experimental": false,
"base_block": "custom_crop_block"
},
"components": {
...
"minecraft:loot": {
"table": "loot_tables/blocks/customcrop_stage2.json"
}
...
}
}
}
```
该阶段为农作物的成熟阶段可以通过minecraft:loot的方式获得收获。
### 3成长过程
<img src="../../picture/customcrop/custom_stage_2.jpg" alt="流程" style="zoom:75%;" />
其中中间为阶段一customcrop:customcrop_stage0最右边为阶段二customcrop:customcrop_stage1左边为阶段三customcrop:customcrop_stage2
## 自定义农作物方式二
该方式适用于配置json+python脚本控制。
这种方式包括一个物品(自定义物品)与三种自定义农作物的状态(自定义方块)。
这种方式需要配置[netease:random_tick](../1-JSON组件.md#netease_random_tick)和[netease:block_entity](../1-JSON组件.md#netease_block_entity),使得<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockrandomtickserverevent" rel="noopenner"> BlockRandomTickServerEvent事件 </a>发送到脚本层并且支持[自定义方块实体](../4-自定义方块实体.md),从而实现方块转换的控制以及方块状态的存档。
#### 1自定义物品
在示例mod中该自定义物品为customcrop:custom_item在该物品的使用时通过监听事件<a href="../../../../../mcdocs/1-ModAPI/事件/物品.html#serveritemuseonevent" rel="noopenner"> ServerItemUseOnEvent </a>来判断是否可以在当前位置种植该物品类似customcrop:custom_wheat_seeds的minecraft:seed中的plant_at功能并且通过<a href="../../../../../mcdocs/1-ModAPI/接口/世界/方块管理.html#setblocknew" rel="noopenner"> SetBlockNew </a>设置农作物阶段一customcrop:customcrop_1_stage0
#### 2自定义三种农作物状态
##### customcrop:customcrop_1_stage0
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_1_stage0",
"register_to_creative_menu": true,
"is_experimental": false
},
"components": {
...
"netease:random_tick": { # 该方块会触发BlockRandomTickServerEvent事件
"enable": true,
"tick_to_script": true
},
"netease:redstone_property": {
"value": "break_on_push"
},
"netease:neighborchanged_sendto_script": {# 该方块会触发BlockNeighborChangedServerEvent事件
"value": true
},
"netease:block_entity": { # 方块实体数据存储
"tick": false,
"movable": true
}
}
}
}
```
##### customcrop:customcrop_1_stage1
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_1_stage1",
"register_to_creative_menu": true,
"is_experimental": false
},
"components": {
...
"netease:random_tick": {
"enable": true,
"tick_to_script": true
},
"netease:redstone_property": {
"value": "break_on_push"
},
"netease:neighborchanged_sendto_script": {
"value": true
},
"netease:block_entity": {
"tick": false,
"movable": true
}
}
}
}
```
##### customcrop:customcrop_1_stage2
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customcrop:customcrop_1_stage2",
"register_to_creative_menu": true,
"is_experimental": false
},
"components": {
...
"netease:neighborchanged_sendto_script": {
"value": true
},
"netease:block_entity": {
"tick": false,
"movable": true
}
}
}
}
```
#### 3生长过程
<img src="../../picture/customcrop/custom_stage_1.jpg" alt="流程" style="zoom:75%;" />
其中左边为阶段一customcrop:customcrop_1_stage0中间为阶段二customcrop:customcrop_1_stage2右边为阶段三customcrop:customcrop_1_stage2
#### 4脚本简要说明
##### 物品使用条件限定
在自定义物品customcrop:custom_item使用生成农作物第一阶段方块customcrop:customcrop_1_stage0可以通过监听事件<a href="../../../../../mcdocs/1-ModAPI/事件/物品.html#serveritemuseonevent" rel="noopenner"> ServerItemUseOnEvent </a>来限制,例如:
```python
def OnServerItemUseOnEvent(self, args):
if args["itemName"] == "customcrop:custom_item":
# 使用自定义物品时生成自定义方块
comp = self.CreateComponent(self.playerId, "Minecraft", "blockInfo")
belowPos = (args["x"], args["y"], args["z"]) # below
blockDict = comp.GetBlockNew(belowPos)
if blockDict["name"] == "minecraft:dirt": # 底下为泥土才能种植这里同种子的plant_at判断
blockDict = {
'name': 'customcrop:customcrop_1_stage0',
'aux': 0
}
comp.SetBlockNew((args["x"], args["y"] + 1, args["z"]), blockDict)
```
##### 农作物转换条件
在示例mod中我们通过监听事件<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockrandomtickserverevent" rel="noopenner"> BlockRandomTickServerEvent </a>来判断是否可以转换到下一个阶段的自定义农作物判断条件不限定于netease:transform中描述的光照、tick数量以及周边环境。同时我们还可以借助blockEntityData组件来存储数据。
```python
def OnStage0BlockTick(self, args):
pos = (args["posX"], args["posY"], args["posZ"])
comp = self.CreateComponent(self.playerId, "Minecraft", "blockInfo")
lightlevel = comp.GetBlockLightLevel(pos)
if (15 >= lightlevel >= 0): # 光照条件判断
dimension = args["dimensionId"]
blockEntitycomp = self.CreateComponent(self.playerId, "Minecraft", "blockEntityData")
blockEntityData = blockEntitycomp.GetBlockEntityData(dimension, pos)
if not blockEntityData:
return
growth = blockEntityData["growth"]
if not growth:
growth = 0
growth += 1
# 使用blockEntity保存tick count数据
blockEntityData["growth"] = growth
if (growth >= 1): # tick数量条件判断
comp = self.CreateComponent(self.playerId, "Minecraft", "blockInfo")
blockDict = {
'name': 'customcrop:customcrop_1_stage1',
'aux': 0
}
comp.SetBlockNew(pos, blockDict) # 切换到农作物的下一个阶段
```
##### 农作物收获
开发者可以根据需要,通过监听事件<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#destroyblockevent" rel="noopenner"> DestroyBlockEvent </a>以及<a href="../../../../../mcdocs/1-ModAPI/接口/世界/实体管理.html#spawnitemtolevel" rel="noopenner"> SpawnItemToLevel </a>来实现农作物的掉落。
## 自定义农作物外观
- 可使用[自定义方块模型](../5-自定义方块模型.md)配置农作物的外观。
demo的`resource/bbmodel`下有demo中农作物的模型工程demo中所有农作物都共用一个工程只是贴图不一样。
## Q&A
1什么时候需要把自定义方块base_block配置成custom_crop_block
需要[netease:transform组件](#netease_transform)驱动方块之间的转换时
2如何限制农作物的种植条件
使用“自定义农作物方式一“的方式可以通过种子的”plant_at“字段进行限制
使用“自定义农作物方式二”的方式可以通过监听<a href="../../../../../mcdocs/1-ModAPI/事件/物品.html#serveritemuseonevent" rel="noopenner"> ServerItemUseOnEvent </a>来限制种植时的条件。
3自定义农作物下方的方块被破坏、被替换、被推动时如何检测
监听<a href="../../../../../mcdocs/1-ModAPI/事件/方块.html#blockneighborchangedserverevent" rel="noopenner"> BlockNeighborChangedServerEvent </a>事件监听周围方块的变化,并做响应的处理。

View File

@@ -0,0 +1,67 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义红石方块
自定义红石方块是一种特殊的自定义方块,包括信号源方块与红石机械元件方块,支持方块相关的所有事件以及接口。
## 自定义红石信号源方块
自定义红石信号源方块放置在地图上会发出红石信号,信号的初始值可以配置。
其中type为producerstrength为初始红石信号量。
```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"
}
}
}
}
```

View File

@@ -0,0 +1,149 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义流体
## 概述
自定义流体需要设置两个方块,一个静态流体,一个动态流体。液体在流动过程中最外层是动态流体,其他都是静态流体,二者会相互转换。当流体扩散完毕后可见的均已转化为静态流体,可以通过设置不同颜色来观察动态流体与静态流体之间的相互转换。
## base_block设置
- 自定义流体的**base_block**,静态流体需要设为**liquid**,动态流体需要设为**flowing_liquid**
- 命名规则因为静态流体与动态流体是相互转换的在引擎层通过flowing去定位所以需要注册一对才能正常使用
- 静态流体——**命名空间:流体方块名**,例如`customLiquid:red_water`
- 动态流体——**命名空间:flowing_流体方块名**,例如`customLiquid:flowing_red_water`
## 动画纹理
- 流体需要在`resource/textures/flipbook_textures.json`中配置动画纹理使其贴图拥有动态流动效果,属于微软功能。
## 流体方块介绍
- 可在netease:liquid中设置流体方块的流动速度、流动范围、颜色以及能否使船浮起来
- 流体方块与原版水一致,如图所示:
![special-4](.././picture/customblock/special-5.png)
## netease:liquid
| 键 | 类型 | 默认值 | 解释 |
| -------------- | ------------- | ---------------------------------------- | ------------------------------------------------------------ |
| liquid_color | array | [255, 255, 255, 255] | 可选流体颜色4个数依次对应RGBA取值范围均为0-255。透明度只有在开启了“精美图像”选项时生效。 |
| spread_range | int | 8 | 可选流体范围以动态流体为中心往外扩散的格数取值范围1-8仅动态流体有效 |
| spread_delay | int | 5 | 可选流体扩散刻数每经过该刻数扩散一格每秒20刻仅动态流体有效 |
| spread_fire | bool | false | 可选,是否传播火,可参考岩浆效果 |
| can_float_boat | bool | true | 可选,流体是否能浮起船来,动态流体及静态流体均需要设置 |
| bucket_name | string | "water_bucket" | 可选空桶对水源使用使获得的物品默认是原版的水桶如果是自定义物品需带上命名空间输入完整的物品id |
| water_splash | string | "minecraft:water_splash_particle_manual" | 可选,实体进入流体时会播放对应的粒子特效,在玩家所在位置附近随机播放若干该特效,特效需采用微软特效 |
| mob_effects | array(dict) | [] | 可选,实体进入流体时添加状态效果,会触发对应的添加/刷新状态效果的事件 |
| remove_effects | array(string) | [] | 可选,实体进入流体时移除状态效果,会触发对应的移除状态效果的事件 |
- 如果没有注册该组件,液体颜色、范围及扩散延迟默认和原版水一样,**但是将无法使船浮起来**
添加状态效果mob_effects各字段配置如下
| 键 | 类型 | 解释 |
| ------------- | ------ | -------------------------------------------- |
| effect_name | string | 状态效果名称 |
| duration | int | 状态效果持续时间 |
| amplifier | int | 状态效果倍率比等级小1例如力量II的倍率为1 |
| show_particle | bool | 是否显示状态效果的粒子效果,默认不显示 |
## 自定义流体方块相关特性
- 可以在游戏内通过指令/setblock放置方块静态方块放置后不会向周围扩散当其周围方块发生变化时会转变成流动方块继承流动特性
- 继承自原版水,因此会有原版水的特性,例如和岩浆有互动、玩家进入会有流动效果、溺水、与海绵互动等。
- 用水桶装载后会生成普通水桶通过配置bucket_name可实现生成别的物品可结合自定义桶实现自定义流体的装载与倒出
## 示例
动态流体:
```json
{
"format_version": "1.16.0",
"minecraft:block": {
"description": {
"identifier": "customblocks:flowing_green_water",
"register_to_creative_menu": true,
"base_block": "flowing_liquid"
},
"components": {
"netease:liquid": {
"liquid_color": [ 0, 128, 0, 254 ],
"spread_range": 4,
"spread_delay": 5,
"bucket_name": "customBucket:green_bucket",
"spread_fire": true,
"mob_effects": [
{
"effect_name": "slowness",
"duration": 3,
"amplifier": 1,
"show_particle": true
},
{
"effect_name": "weakness",
"duration": 1,
"amplifier": 4
}
],
"remove_effects": [ "speed", "jump_boost" ]
}
}
}
}
```
静态流体:
```json
{
"format_version": "1.16.0",
"minecraft:block": {
"description": {
"identifier": "customblocks:green_water",
"register_to_creative_menu": false,
"base_block": "liquid"
},
"components": {
"netease:liquid": {
"liquid_color": [ 0, 128, 0, 254 ],
"bucket_name": "customBucket:green_bucket",
"spread_fire": true,
"mob_effects": [
{
"effect_name": "slowness",
"duration": 3,
"amplifier": 1,
"show_particle": true
},
{
"effect_name": "weakness",
"duration": 1,
"amplifier": 4
}
],
"remove_effects": [ "speed", "jump_boost" ]
}
}
}
}
```

View File

@@ -0,0 +1,73 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义重力方块
## 概述
自定义重力方块可以模拟[下落的方块](https://zh.minecraft.wiki/w/%E4%B8%8B%E8%90%BD%E7%9A%84%E6%96%B9%E5%9D%97)并且支持在组件中修改配置、python监听事件。
## base_block设置
- 自定义重力方块的base_block需要设为`custom_heavy_block`
## netease:fall
| 键 | 类型 | 默认值 | 解释 |
| ------------ | ----- | -------------------- | ------------------------------------------------------------ |
| send_python_event | bool | false | 可选,是否发送重力方块/下落方块实体相关事件至python |
| fall_acceleration | float | 0.04 | 可选下落的方块实体每次tick的垂直加速增量 |
| adjust_percentage | float | 0.98 | 可选下落的方块实体每次tick移动完后移速乘的调整数值 |
| hurt_entity | bool | false | 可选,下落的方块实体结束下落后是否要计算对碰撞实体的伤害 |
| fall_damage_amount | float | 2.0 | 可选,原版下落伤害计算完后乘的倍率 |
| max_fall_damage | int | 40 | 可选,下落伤害乘完倍率后也会被限制在该值的范围内 |
| min_height_remove_tick | int | 100 | 可选当下落的方块实体低于区块最低高度后多少tick将其强制删除 |
| force_break_tick | int | 600 | 可选下落的方块实体多少tick后会强制被破坏 |
| cancel_drop | bool | false | 可选,下落的方块实体被破坏时是否取消方块物品的掉落 |
- `send_python_event`主要影响HeavyBlockStartFallingServerEvent、FallingBlockCauseDamageBeforeServerEvent、FallingBlockBreakServerEvent、FallingBlockReturnHeavyBlockServerEvent、FallingBlockCauseDamageBeforeClientEvent几个事件。
- 如果没有在mod程序中监听的需要可以不将`send_python_event`设为true以优化性能不发python事件也可以配置组件的其他值
- 原版对于下落的方块实体计算下落的过程使用python伪代码表示大致为
```python
while Tick:
falling_block.move_vector.y -= fall_acceleration # 当前移动向量增加一个向下的力
move(falling_block) # 按照当前的移动向量调整实体位置
falling_block.move_vector *= adjust_percentage # 移动完后将当前移速(移动向量)乘个数值回调
```
- 原版下落的方块实体并没有对实体实时的碰撞检测,这就意味着在调整下落的方块移动速度时可能会遇到两个问题:
- 如果两个下落的方块速度不一致,会看到一个方块实体从另一个方块实体传过去,并没有碰撞效果。
- 下落的方块对实体造成伤害的计算并不是在刚接触到实体时,而是在落地时才检测范围有无实体,把移速调整的慢点更容易观察到此现象。
## 示例配置
可参考[CustomBlocksMod](../../../13-模组SDK编程/60-Demo示例.md#CustomBlocksMod)中的customblocks:customblocks_test_heavy.json。
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"identifier": "customblocks:customblocks_test_heavy",
"register_to_creative_menu": true,
"is_experimental": false,
"base_block": "custom_heavy_block",
"category": "custom"
},
"components": {
"netease:fall": {
"send_python_event":true,
"fall_acceleration":0.04,
"adjust_percentage":0.98,
"hurt_entity":true,
"min_height_remove_tick":100,
"force_break_tick":600,
"fall_damage_amount":2.0,
"max_fall_damage":40
}
}
}
}
```

View File

@@ -0,0 +1,133 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义含水方块
## 概述
自定义含水方块支持在组件中配置自定义方块含水的相关功能并支持python监听事件、接口设置等。
## netease:water_destory
可在netease:water_destory组件中设置是否无法摆放在水源和流水方块中如果设置为true会被流水摧毁。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | -------------------------------------------- |
| value | bool | | 必须设置,用于设置无法摆放在水源和流水方块中 |
- 可以在方块的loottable中设置被水流摧毁后的掉落物
### 示例
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"register_to_creative_menu": true,
"identifier": "customblocks:water_destroy_test_block",
"is_experimental": false,
"category": "custom"
},
"components": {
"netease:water_destory": {
"value": true
}
}
}
}
```
## netease:water_only
可在netease:water_only组件中设置是否必须放置在水中。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | ------------------------------------ |
| value | bool | | 必须设置,用于设置是否必须放在水中。 |
### 示例
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"register_to_creative_menu": true,
"identifier": "customblocks:water_only_test_block",
"is_experimental": false,
"category": "custom"
},
"components": {
"netease:water_only": {
"value": true
}
}
}
}
```
## netease:water_source
可在netease:water_source组件中设置是否在水源方块中表现为含水。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | -------------------------------------- |
| value | bool | | 必须设置,是否在水源方块中表现为含水。 |
### 示例
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"register_to_creative_menu": true,
"identifier": "customblocks:water_source_test_block",
"is_experimental": false,
"category": "custom"
},
"components": {
"netease:water_source": {
"value": true
},
"netease:render_layer": {
"value": "alpha"
}
}
}
}
```
## netease:water_flow_source
可在netease:water_flow_source组件中设置是否在水源和流水方块中表现为含水。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | -------------------------------------- |
| value | bool | | 必须设置,是否在水源和流水方块中表现为含水。 |
### 示例
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"register_to_creative_menu": true,
"identifier": "customblocks:water_flow_source_test_block",
"is_experimental": false,
"category": "custom"
},
"components": {
"netease:water_flow_source": {
"value": true
},
"netease:render_layer": {
"value": "alpha"
}
}
}
}
```

View File

@@ -0,0 +1,56 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义交叉贴图方块
## 概述
自定义交叉贴图方块支持使用引擎预设的交叉贴图模型,自己配置物品贴图和模型贴图,制作出类似于甘蔗、蜘蛛网的模型方块。
![web_reeds.png](../picture/customblock/web_reeds.png)
## model_item_texture
可在model_item_texture中设置使用的物品贴图。
| 类型 | 默认值 | 解释 |
| ------ | ------ | ----------------------------------------------- |
| string | | 使用的物品贴图,必须设置"netease_model"才能生效 |
## model_texture
可在model_texture中设置使用的模型贴图。
| 类型 | 默认值 | 解释 |
| ----- | ------ | ----------------------------------------------- |
| array | | 使用的模型贴图,必须设置"netease_model"才能生效 |
- model_texture和model_item_texture必须同时设置才能生效
## 使用交叉贴图模型
- 在resource_packs\blocks.json下面添加自定义的方块identifier的配置
- 在"netease_model"里配置"customblocks:web_preset""model_item_texture"和"model_textures"根据需求配置自己的物品贴图和模型贴图
### blocks.json示例
```json
{
"format_version": [
1,
1,
0
],
"customblocks:web_preset": {
"netease_model": "customblocks:web_preset",
"model_item_texture": "customblocks:reeds_item",
"model_textures": [
"customblocks:reeds"
]
}
}
```

View File

@@ -0,0 +1,70 @@
---
front:
hard: 入门
time: 分钟
---
# 自定义含雪方块
## 概述
自定义含雪方块支持在组件中配置自定义方块含雪的相关功能并支持python监听事件、接口设置等。
需要配置方块含雪,需设置以下两个组件
## netease:snow_recover_able
可在netease:snow_recover_able组件中设置方块是否能含雪。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | -------------------------------- |
| value | bool | | 必须设置,用于设置方块是否能含雪 |
## netease:can_built_over
可在netease:can_built_over组件中设置在放置其他方块时如果该位置已有含netease:can_built_over配置的方块其他方块能否和放置在此方块中。
| 键 | 类型 | 默认值 | 解释 |
| ----- | ---- | ------ | ------------------------------------------------------------ |
| value | bool | | 必须设置用于设置在放置其他方块时如果该位置已有含netease:can_built_over配置的方块其他方块能否和放置在此方块中 |
### 示例
```json
{
"format_version": "1.10.0",
"minecraft:block": {
"description": {
"register_to_creative_menu": true,
"identifier": "customblocks:customblocks_test_ore",
"is_experimental": false,
"category": "custom"
},
"components": {
"minecraft:block_light_absorption": {
"value": 0
},
"netease:render_layer": {
"value": "alpha"
},
"netease:snow_recover_able": {
"value": true
},
"netease:can_built_over": {
"value": true
},
"netease:aabb": {
"collision": {
"min": [0.0, 0.0, 0.0],
"max": [0.0, 0.0, 0.0]
},
"clip": {
"min": [0.0, 0.0, 0.0],
"max": [1.0, 0.188, 1.0]
}
}
}
}
}
```
## 注意
目前自定义含雪方块和方块实体不兼容(包括自定义方块实体,自定义刷怪箱等),请不要一起使用