跳转到正文

subchunk API ​

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

模块说明 ​

text
Bounded read-only views of neomega.subchunk.v1 (NSC v1) objects.

Parsing does no I/O and does not establish transfer integrity: verify the bulk
transfer before using its bytes. Epoch, dimension and revision belong to the
separate snapshot metadata. Runtime ID zero is not implicitly air. Raw block
entity NBT remains in its declared encoding; __tag is never expanded here.

MAX_OBJECT_BYTES ​

python
MAX_OBJECT_BYTES = 1 << 20

NBTRecord ​

python
@dataclass(frozen=True, slots=True)
class NBTRecord

字段(包含继承字段):

NBTRecord.encoding ​

python
encoding: str

数据类字段;声明于 subchunk.NBTRecord。

NBTRecord.data ​

python
data: bytes

数据类字段;声明于 subchunk.NBTRecord。

SubChunkView ​

python
@dataclass(frozen=True, slots=True)
class SubChunkView

该类型另有以下内部字段,参与数据类声明但不建议直接读写;创建对象时优先使用专题中的工厂方法:

python
_data: bytes
_layers: tuple[tuple[int, int], ...]
_nbt: Mapping[int, tuple[str, int, int]]
_nbt_complete: bool

SubChunkView.layer_count ​

python
@property
def layer_count(self) -> int

SubChunkView.nbt_count ​

python
@property
def nbt_count(self) -> int

SubChunkView.nbt_complete ​

python
@property
def nbt_complete(self) -> bool

SDK 说明:

text
Whether absent cells are known to have no NBT in this observation.

SubChunkView.block ​

python
def block(self, x: int, y: int, z: int, layer: int=0) -> int | None

SubChunkView.nbt ​

python
def nbt(self, x: int, y: int, z: int) -> NBTRecord | None

SDK 说明:

text
Return owned raw bytes; None alone is not proof of absence if incomplete.

parse_subchunk ​

python
def parse_subchunk(data: bytes | bytearray | memoryview) -> SubChunkView

SDK 说明:

text
Validate a complete bounded object; malformed input raises ValueError.

Immutable bytes are retained. Other supported buffers are copied before
validation, including read-only views over mutable backing storage. Layer
palettes/indices remain packed bytes instead of per-cell Python objects.

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