15 KiB
sidebarDepth
| sidebarDepth |
|---|
| 1 |
方块管理
GetBlock
客户端
method in mod.client.component.blockInfoCompClient.BlockInfoComponentClient
-
描述
获取某一位置的block
-
参数
参数名 数据类型说明 pos tuple(float,float,float) 方块位置 -
返回值
数据类型说明 tuple(str,int) 参数1:方块的名称,参数2:方块的附加值AuxValue -
备注
- 已经加载的地形才设置、获取方块信息
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetBlock((x,y,z))
GetBlockClip
服务端客户端
服务端接口
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取某一位置方块当前clip的aabb
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 dimensionId int 方块所在维度,不填时默认为-1 -
返回值
数据类型说明 dict 方块clip的aabb字典 -
备注
- 已经加载的地形才能获取方块信息,支持获取对应维度的常加载区块内方块信息
- 由于方块的碰撞盒可以随临近方块改变而改变,因此该接口返回的是调用时方块clip的aabb
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockClip((0, 5, 0), 0)
客户端接口
method in mod.client.component.blockInfoCompClient.BlockInfoComponentClient
-
描述
获取指定位置方块当前clip的aabb
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 -
返回值
数据类型说明 dict 方块aabb字典 -
备注
- 由于方块的碰撞盒可以随临近方块改变而改变,因此该接口返回的是调用时方块clip的aabb
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetBlockClip((x,y,z))
GetBlockCollision
服务端客户端
服务端接口
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取某一位置方块当前collision的aabb
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 dimensionId int 方块所在维度,不填时默认为-1 -
返回值
数据类型说明 dict 方块aabb字典 -
备注
- 已经加载的地形才能获取方块信息,支持获取对应维度的常加载区块内方块信息
- 由于方块的碰撞盒可以随临近方块改变而改变,因此该接口返回的是调用时方块collision的aabb
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockCollision((0, 5, 0), 0)
客户端接口
method in mod.client.component.blockInfoCompClient.BlockInfoComponentClient
-
描述
获取指定位置方块当前collision的aabb
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 -
返回值
数据类型说明 dict 方块aabb字典 -
备注
- 由于方块的碰撞盒可以随临近方块改变而改变,因此该接口返回的是调用时方块collision的aabb
-
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetBlockCollision((x,y,z))
GetBlockNew
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取某一位置的block
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 dimensionId int 方块所在维度 -
返回值
数据类型说明 dict 方块信息字典 -
备注
- 已经加载的地形才能获取方块信息,支持获取对应维度的常加载区块内方块信息
- 对于有多种状态的方块,aux计算比较复杂,推荐使用GetBlockStates获取方块状态字典
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
blockDict = comp.GetBlockNew((0, 5, 0), 0)
GetDestroyTotalTime
服务端客户端
服务端接口
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取使用物品破坏方块需要的时间
-
参数
参数名 数据类型说明 blockName str 方块标识符,格式[namespace:name:auxvalue],auxvalue默认为0 itemName str 物品标识符,格式[namespace:name:auxvalue],auxvalue默认为0,默认为None(不使用物品) -
返回值
数据类型说明 float 需要消耗的时间 -
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetDestroyTotalTime("minecraft:diamond_block", "minecraft:stone_pickaxe")
客户端接口
method in mod.client.component.blockInfoCompClient.BlockInfoComponentClient
-
描述
获取使用物品破坏方块需要的时间
-
参数
参数名 数据类型说明 blockName str 方块标识符,格式[namespace:name:auxvalue],auxvalue默认为0 itemName str 物品标识符,格式[namespace:name:auxvalue],auxvalue默认为0,默认为None(不使用物品) -
返回值
数据类型说明 float 需要消耗的时间 -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.GetDestroyTotalTime("minecraft:diamond_block", "minecraft:stone_pickaxe")
GetLiquidBlock
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取某个位置方块所含流体信息接口
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 dimensionId int 方块所在维度 -
返回值
数据类型说明 dict 方块信息字典 -
备注
- 已经加载的地形才能获取方块信息,支持获取对应维度的常加载区块内方块信息
- 对于不含水或者不是流体的方块,则返回None。对于一个含水的方块,如含水的橡木栅栏,GetLiquidBlock会返回其含有的流体的信息(包括自定义流体),GetBlockNew则会返回橡木栅栏的信息。而对于一般的水方块(包括自定义流体),GetLiquidBlock和GetBlockNew则都会返回水的信息(包括自定义流体)。因此可以用GetLiquidBlock和GetBlockNew判断某个方块是否流体
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
liquidBlockDict = comp.GetLiquidBlock((0, 5, 0), 0)
GetTopBlockHeight
服务端客户端
服务端接口
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
获取某一位置最高的非空气方块的高度
-
参数
参数名 数据类型说明 pos tuple(int,int) x轴与z轴位置 dimension int 维度id,默认为0,可在获取常加载区块内最高非空气方块高度 -
返回值
数据类型说明 int或None 高度。若区块未加载返回None -
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
height = comp.GetTopBlockHeight((5, 5), 0)
客户端接口
method in mod.client.component.blockInfoCompClient.BlockInfoComponentClient
-
描述
获取当前维度某一位置最高的非空气方块的高度
-
参数
参数名 数据类型说明 pos tuple(int,int) x轴与z轴位置 -
返回值
数据类型说明 int或None 高度。若区块未加载返回None -
示例
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateBlockInfo(levelId)
height = comp.GetTopBlockHeight((5, 5))
SetBlockNew
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
设置某一位置的方块
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 blockDict dict 方块信息字典 oldBlockHandling int 0:替换,1:销毁,2:保留,默认为0 dimensionId int 方块所在维度,必需参数 isLegacy bool 是否设置为传统的aux,建议设置为True,即aux对应的state不随着版本迭代而变化。默认为False -
返回值
数据类型说明 bool 设置结果 -
备注
- 已经加载的地形才能设置方块,支持在对应维度的常加载区块内设置方块
- 若使用SetBlockNew接口替换含方块实体的方块,除自定义方块实体外,当替换前后方块实体类型相同时,其方块实体内数据不会发生改变。
例如在箱子中放置了物品,使用SetBlockNew接口将箱子方块替换为箱子方块后,新的箱子中依然保留旧箱子内的物品。
要避免这种情况,中间添加一次不同方块实体类型(或不含方块实体)的方块替换即可。比如先将箱子替换为空气,再将空气替换为箱子。 - 随着版本更新,aux值对应的方块state会发生改变,对于有多种状态的方块,aux计算方式比较复杂,推荐先通过GetBlockAuxValueFromStates获取传统aux值再进行设置。
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockState(levelId)
# GetBlockAuxValueFromStates 只需要调用一次,得到的auxValue可以缓存以来以供后续使用
auxValue = comp.GetBlockAuxValueFromStates("minecraft:wool", { 'color': 'orange' })
blockDict = {
'name': 'minecraft:wool',
'aux': auxValue
}
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(levelId)
comp.SetBlockNew((0, 5, 0), blockDict, 0, 0, True)
SetLiquidBlock
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
设置某一位置的方块的extraBlock,可在此设置方块含水等
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 blockDict dict 方块信息字典 dimensionId int 方块所在维度,必需参数 -
返回值
数据类型说明 bool 设置结果 -
备注
- 已经加载的地形才能设置方块,支持在对应维度的常加载区块内设置方块
- dimensionId需要是playerId对应玩家所在的维度;如果dimensionId是-1则默认使用playerId对应玩家所在的维度
-
示例
import mod.server.extraServerApi as serverApi
blockDict = {
'name': 'minecraft:water',
'aux': 5
}
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId)
comp.SetLiquidBlock((0, 5, 0), blockDict, 0)
SetSnowBlock
服务端
method in mod.server.component.blockInfoCompServer.BlockInfoComponentServer
-
描述
设置某一位置的方块含雪
-
参数
参数名 数据类型说明 pos tuple(int,int,int) 方块位置 dimensionId int 方块所在维度,必需参数 height int 雪块的高度,默认是1 -
返回值
数据类型说明 bool 设置结果 -
备注
- 已经加载的地形才能设置方块,支持在对应维度的常加载区块内设置方块
- dimensionId需要是playerId对应玩家所在的维度;如果dimensionId是-1则默认使用playerId对应玩家所在的维度
-
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateBlockInfo(playerId)
comp.SetSnowBlock((0, 5, 0), 0, 1)