前置插件:世界交互
介绍
世界交互主要提供了一些获取世界信息、操作机器人使其与游戏交互的接口。
获取方式
python
from tooldelta import plugins
chatbar = plugins.get_plugin_api("聊天栏菜单")
1
2
3
2
3
接口
get_structure()
python
def get_structure(
position: tuple[int, int, int], size: tuple[int, int, int]
) -> Structure
1
2
3
2
3
- 获取指定坐标处的指定尺寸的结构,可能需要零点几秒的时间或者更久。
- 参数:
- position (tuple[int, int, int]): 结构起点坐标
- size (tuple[int, int, int]): 结构尺寸
- 返回:
- Structure: 结构对象
- 对于这个结构对象,可以用以下方法获取其中包含的信息:
- get_block()
pythondef get_block(self, position: tuple[int, int, int]) -> Block
1- 获取结构中相对坐标处的方块。
- 参数:
- position (tuple[int, int, int]): 方块在结构中的相对坐标
- 返回:
- Block: 方块对象
Block
对象拥有如下信息:- name (str): 方块 ID,如
minecraft:air
- state (dict[str, Any]): 方块状态
- val (int): 方块特殊值
- version (int): 此方块的版本
- metadata (Any | None): 方块的附带 NBT 信息
- name (str): 方块 ID,如
make_packet_command_block_update()
python
def make_packet_command_block_update(
position: tuple[int, int, int],
command: str,
mode: int = 0,
need_redstone: bool = False,
tick_delay: int = 0,
conditional: bool = False,
name: str = "",
should_track_output: bool = True,
execute_on_first_tick: bool = True,
) -> dict[str, Any]
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
- 创建一个更新命令方块内容的数据包。
- 参数:
- position (tuple[int, int, int]):命令方块的坐标
- command (str):命令方块中的指令
- mode (int):命令方块的模式,默认为 0,0=脉冲型,1=循环型,2=连锁型
- need_redstone (bool):是否为需要红石信号激活,默认为 False
- tick_delay (int):命令方块的执行间隔,默认为 0
- conditional (bool):是否为条件型命令方块,默认为 False
- name (str):命令方块的显示名称,默认为 ""
- should_track_output (bool):是否记上一次输出,默认为 True
- execute_on_first_tick (bool):是否在第一次执行时立刻执行,默认为 True
place_command_block()
python
def place_command_block(
command_block_update_packet,
facing=0,
limit_seconds=0.0,
limit_seconds2=0.0,
in_dim="overworld",
)
1
2
3
4
5
6
7
2
3
4
5
6
7
- 放置一个命令方块。
- 参数:
- command_block_update_packet (dict[str, Any]):使用
make_packet_command_block_update()
创建的命令方块数据包 - facing (int):命令方块的朝向,默认为 0
- limit_seconds (float):从tp到对应坐标至放置命令方块的延迟,默认为 0.5
- limit_seconds2 (float):从放置方块到写入命令的延迟,默认为 0.5
- in_dim (str):放置命令方块的维度,默认为 "overworld"
- command_block_update_packet (dict[str, Any]):使用