跳转到正文

environment API ​

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

模块说明 ​

text
Connection-local environment evidence, never an inferred world truth.

Read a value only when its field's known flag is true. A zero/false wire value
with known=false is a placeholder, not evidence. Cursor mismatches and gaps
must be handled before comparing revisions or updating a caller's projection.

EnvironmentCursor ​

python
class EnvironmentCursor(TypedDict)

字段(包含继承字段):

EnvironmentCursor.connection_id ​

python
connection_id: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentCursor.epoch ​

python
epoch: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentCursor.revision ​

python
revision: int

必填;声明于 environment.EnvironmentCursor。

EnvironmentObserved ​

python
class EnvironmentObserved(TypedDict)

字段(包含继承字段):

EnvironmentObserved.known ​

python
known: bool

必填;声明于 environment.EnvironmentObserved。

EnvironmentObserved.value ​

python
value: bool | int | float

必填;声明于 environment.EnvironmentObserved。

EnvironmentObserved.source ​

python
source: str

必填;声明于 environment.EnvironmentObserved。

EnvironmentObserved.revision ​

python
revision: int

必填;声明于 environment.EnvironmentObserved。

EnvironmentGameRule ​

python
class EnvironmentGameRule(EnvironmentObserved)

字段(包含继承字段):

EnvironmentGameRule.known ​

python
known: bool

必填;声明于 environment.EnvironmentObserved。

EnvironmentGameRule.value ​

python
value: bool | int | float

必填;声明于 environment.EnvironmentObserved。

EnvironmentGameRule.source ​

python
source: str

必填;声明于 environment.EnvironmentObserved。

EnvironmentGameRule.revision ​

python
revision: int

必填;声明于 environment.EnvironmentObserved。

EnvironmentGameRule.type ​

python
type: str

必填;声明于 environment.EnvironmentGameRule。

EnvironmentGameRule.can_be_modified_by_player ​

python
can_be_modified_by_player: bool

必填;声明于 environment.EnvironmentGameRule。

EnvironmentLocalWeather ​

python
class EnvironmentLocalWeather(TypedDict)

字段(包含继承字段):

EnvironmentLocalWeather.source ​

python
source: str

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.revision ​

python
revision: int

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.rain_level ​

python
rain_level: float

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.lightning_level ​

python
lightning_level: float

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.rain_time ​

python
rain_time: int

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.lightning_time ​

python
lightning_time: int

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentLocalWeather.is_weather_cycle ​

python
is_weather_cycle: bool

必填;声明于 environment.EnvironmentLocalWeather。

EnvironmentSnapshot ​

python
class EnvironmentSnapshot(EnvironmentCursor, _EnvironmentReadMetadata)

字段(包含继承字段):

EnvironmentSnapshot.connection_id ​

python
connection_id: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentSnapshot.epoch ​

python
epoch: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentSnapshot.revision ​

python
revision: int

必填;声明于 environment.EnvironmentCursor。

EnvironmentSnapshot.source ​

python
source: str

可省略;声明于 environment._EnvironmentReadMetadata。

EnvironmentSnapshot.gap ​

python
gap: bool

可省略;声明于 environment._EnvironmentReadMetadata。

EnvironmentSnapshot.complete_world_coverage ​

python
complete_world_coverage: bool

可省略;声明于 environment._EnvironmentReadMetadata。

EnvironmentSnapshot.connected_at ​

python
connected_at: str

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.time ​

python
time: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.world_age ​

python
world_age: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.day_cycle_lock_time ​

python
day_cycle_lock_time: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.rain_level ​

python
rain_level: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.lightning_level ​

python
lightning_level: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.raining ​

python
raining: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.thundering ​

python
thundering: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.dimension ​

python
dimension: EnvironmentObserved

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.game_rules ​

python
game_rules: dict[str, EnvironmentGameRule]

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.game_rules_observed ​

python
game_rules_observed: bool

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.dimension_weather ​

python
dimension_weather: dict[str, EnvironmentLocalWeather]

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.gaps ​

python
gaps: list[str]

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentSnapshot.reset_reason ​

python
reset_reason: str

必填;声明于 environment.EnvironmentSnapshot。

EnvironmentEvent ​

python
class EnvironmentEvent(EnvironmentCursor, _EnvironmentEventDetails)

字段(包含继承字段):

EnvironmentEvent.connection_id ​

python
connection_id: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentEvent.epoch ​

python
epoch: str

必填;声明于 environment.EnvironmentCursor。

EnvironmentEvent.revision ​

python
revision: int

必填;声明于 environment.EnvironmentCursor。

EnvironmentEvent.event_type ​

python
event_type: int

可省略;声明于 environment._EnvironmentEventDetails。

EnvironmentEvent.kind ​

python
kind: str

必填;声明于 environment.EnvironmentEvent。

EnvironmentEvent.source ​

python
source: str

必填;声明于 environment.EnvironmentEvent。

EnvironmentEvent.event_data ​

python
event_data: int

必填;声明于 environment.EnvironmentEvent。

EnvironmentEvent.gap ​

python
gap: bool

必填;声明于 environment.EnvironmentEvent。

EnvironmentEvent.complete_world_coverage ​

python
complete_world_coverage: bool

必填;声明于 environment.EnvironmentEvent。

EnvironmentEvent.snapshot ​

python
snapshot: EnvironmentSnapshot

必填;声明于 environment.EnvironmentEvent。

Environment ​

python
class Environment

Environment.__init__ ​

python
def __init__(self, operations: Operations)

Environment.observe ​

python
def observe(
    self,
    *,
    idempotency_key: str,
    deadline: str,
    after: EnvironmentCursor | None = None,
) -> OperationIntent

SDK 说明:

text
Prepare framework.environment.observe without IO.

The successful result is EnvironmentSnapshot. after requests continuity
diagnostics, not replay. Each fresh read requires a fresh caller-chosen
key; reusing a key returns the previous operation's receipt.

Environment.operations ​

python
self.operations

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

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