跳转到正文

game API ​

完整接口目录 · 世界与方块用法 · 工具包下载

模块说明 ​

text
Named intent builders for native game actions; all execution uses Operations.

Prepared intents can be attached to a storage/event transaction. Keys and fixed
deadlines stay explicit so a lost reply cannot silently create a second action.
Host validates arguments and grants before admission. Read terminal evidence.

CommandMessage ​

python
@dataclass(frozen=True)
class CommandMessage

SDK 说明:

text
One server message; text may be a translation key, not localized prose.

字段(包含继承字段):

CommandMessage.success ​

python
success: bool

数据类字段;声明于 game.CommandMessage。

CommandMessage.message ​

python
message: str

数据类字段;声明于 game.CommandMessage。

CommandMessage.parameters ​

python
parameters: tuple[str, ...]

数据类字段;声明于 game.CommandMessage。

CommandOutput ​

python
@dataclass(frozen=True)
class CommandOutput

SDK 说明:

text
Native kernel output; data_set is the native integer, not protocol DataSet.

字段(包含继承字段):

CommandOutput.success_count ​

python
success_count: int

数据类字段;声明于 game.CommandOutput。

CommandOutput.output_type ​

python
output_type: int

数据类字段;声明于 game.CommandOutput。

CommandOutput.data_set ​

python
data_set: int

数据类字段;声明于 game.CommandOutput。

CommandOutput.messages ​

python
messages: tuple[CommandMessage, ...]

数据类字段;声明于 game.CommandOutput。

CommandResult ​

python
class CommandResult

SDK 说明:

text
Copied receipt view. Unknown, absent or mixed output never implies success.

CommandResult.__init__ ​

python
def __init__(self, receipt: OperationReceipt)

CommandResult.receipt ​

python
@property
def receipt(self) -> OperationReceipt

CommandResult.messages ​

python
@property
def messages(self) -> tuple[CommandMessage, ...]

CommandResult.errors ​

python
@property
def errors(self) -> tuple[CommandMessage, ...]

SDK 说明:

text
Failed server messages; absence does not prove success (see reason/state).

CommandResult.message_texts ​

python
@property
def message_texts(self) -> tuple[str, ...]

SDK 说明:

text
Native text verbatim; parameters stay separate to avoid duplicating them.

CommandResult.is_success ​

python
@property
def is_success(self) -> bool

CommandResult.protocol_output ​

python
def protocol_output(self) -> dict

SDK 说明:

text
Return validated original packet fields, or raise CommandOutcomeError.

Uses the existing packet parser; never invents origin or DataSet when
output was omitted. AI output retains its documented inferred shape.

CommandResult.operation_id ​

python
self.operation_id

公开实例属性,在 __init__ 中设置。

CommandResult.state ​

python
self.state

公开实例属性,在 __init__ 中设置。

CommandResult.evidence ​

python
self.evidence

公开实例属性,在 __init__ 中设置。

CommandResult.reason ​

python
self.reason

公开实例属性,在 __init__ 中设置。

CommandResult.output ​

python
self.output

公开实例属性,在 __init__ 中设置。

Commands ​

python
class Commands

Commands.__init__ ​

python
def __init__(self, operations: Operations)

Commands.prepare ​

python
def prepare(
    self,
    command: str,
    *,
    idempotency_key: str,
    deadline: str,
    identity: str = 'ws',
    wait: bool = True,
    timeout: float = 30,
) -> OperationIntent

SDK 说明:

text
wait=True requests an actual response; wo has no response guarantee.

Commands.execute ​

python
async def execute(
    self,
    command: str,
    *,
    idempotency_key: str,
    deadline: str,
    identity: str = 'ws',
    wait: bool = True,
    command_timeout: float = 30,
    submit_timeout = 10,
    timeout = 30,
    poll_interval = 0.05,
) -> OperationReceipt

SDK 说明:

text
Prepare and submit once; return every terminal state without rewriting it.

command_timeout bounds the server-response wait; timeout bounds SDK
polling. Keys/deadlines are caller-owned. Use prepare + operations.execute
when intent must be persisted before IO.

Commands.result ​

python
@staticmethod
def result(receipt: OperationReceipt) -> CommandResult

SDK 说明:

text
Parse a receipt without changing its state, evidence or raw fields.

Commands.operations ​

python
self.operations

公开实例属性,在 __init__ 中设置。

World ​

python
class World

World.__init__ ​

python
def __init__(self, operations: Operations)

World.command_block ​

python
def command_block(
    self,
    pos,
    command: str,
    *,
    mode: int,
    facing: int,
    idempotency_key: str,
    deadline: str,
    need_redstone: bool = False,
    conditional: bool = False,
    tick_delay: int = 0,
    name: str = '',
    track_output: bool = False,
    execute_on_first_tick: bool = False,
) -> OperationIntent

SDK 说明:

text
Configuration readback does not prove redstone execution.

World.sign ​

python
def sign(
    self,
    pos,
    text: str,
    *,
    idempotency_key: str,
    deadline: str,
    back_text: str = '',
    block: str = 'minecraft:standing_sign',
    glow: bool = False,
    back_glow: bool = False,
    waxed: bool = False,
    slot: int = 0,
) -> OperationIntent

World.item ​

python
def item(
    self,
    name: str,
    *,
    slot: int,
    anvil_pos,
    workspace_pos,
    idempotency_key: str,
    deadline: str,
    count: int = 1,
    value: int = 0,
    custom_name: str = '',
) -> OperationIntent

SDK 说明:

text
Verified only after a newer native slot packet matches requested fields.

World.subchunk ​

python
def subchunk(
    self,
    dimension: int,
    pos,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Request only. Read the separate cache to check whether data arrived.

World.enhanced_item ​

python
def enhanced_item(
    self,
    item: dict,
    *,
    slot: int,
    anvil_pos,
    workspace_pos,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Supported book/enchant/banner/component fields; inspect unknown receipts.

World.container ​

python
def container(
    self,
    pos,
    slots: dict,
    *,
    anvil_pos,
    workspace_pos,
    idempotency_key: str,
    deadline: str,
    block: str | None = None,
) -> OperationIntent

SDK 说明:

text
Write at most nine requested slots; other existing slots are not cleared.

World.structure_block ​

python
def structure_block(
    self,
    pos,
    name: str,
    *,
    mode: int,
    size,
    offset,
    idempotency_key: str,
    deadline: str,
    include_players = False,
    ignore_entities = True,
    ignore_blocks = False,
    show_bounding_box = False,
    rotation = 0,
    mirror = 0,
) -> OperationIntent

World.bdx ​

python
def bdx(
    self,
    content: bytes,
    pos,
    *,
    idempotency_key: str,
    deadline: str,
    batch: bool = False,
    paused: bool = False,
    speed: float | None = None,
) -> OperationIntent

SDK 说明:

text
Prepare inline BDX (180 KiB, 256 steps). Batch requires paused chains.

World.bdx_artifact ​

python
def bdx_artifact(
    self,
    artifact_id: str,
    pos,
    *,
    idempotency_key: str,
    deadline: str,
    batch: bool = False,
    paused: bool = False,
    speed: float | None = None,
) -> OperationIntent

SDK 说明:

text
Prepare without IO. First retain the artifact with this exact key.

Use Artifacts.retain before submission. Cancellation never rolls back
placed blocks. Unknown results must be reconciled, not replayed.

World.bdx_file ​

python
async def bdx_file(
    self,
    path,
    pos,
    *,
    idempotency_key: str,
    deadline: str,
    batch: bool = False,
    paused: bool = False,
    speed: float | None = None,
    timeout = 10,
) -> OperationIntent

SDK 说明:

text
Upload a local BDX file (8 MiB), retain, then prepare; never submit.

Keep the returned intent for reconciliation before Operations.submit. This
method does not retry or remove artifacts after an uncertain response.

World.pick_block ​

python
def pick_block(
    self,
    pos,
    *,
    slot: int,
    idempotency_key: str,
    deadline: str,
    assign_nbt: bool = False,
) -> OperationIntent

SDK 说明:

text
Creative PickBlock; returned slot is not proof of NBT fidelity.

World.place_block ​

python
def place_block(
    self,
    pos,
    *,
    slot: int,
    facing: int,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Workspace placement may move the bot and create/remove a helper block.

World.held_on_block ​

python
def held_on_block(
    self,
    pos,
    block: str,
    *,
    slot: int,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Place a lectern/jukebox and click the held book/disc onto it.

World.item_frame ​

python
def item_frame(
    self,
    pos,
    *,
    slot: int,
    idempotency_key: str,
    deadline: str,
    rotation: int = 0,
) -> OperationIntent

SDK 说明:

text
Place a floor-facing frame and support, then insert/rotate held item.

World.export_bdx ​

python
def export_bdx(
    self,
    pos,
    size,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Fresh region <=4096 blocks; result contains an owned artifact + loss list.

Foreground states and command configuration survive; other NBT, air
clearing, background layers and entities do not. Read via artifacts API.

World.save_structure ​

python
def save_structure(
    self,
    name: str,
    pos,
    size,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Save <=4096 blocks to server memory, excluding entities; name may overwrite.

World.load_structure ​

python
def load_structure(
    self,
    name: str,
    pos,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

SDK 说明:

text
Load a named server structure at pos with default rotation/mirror.

Server acknowledgement is not a field-by-field restored-content check.

World.operations ​

python
self.operations

公开实例属性,在 __init__ 中设置。

Neomega · 使用、开发与参考文档