gdpc.world_slice

Provides the WorldSlice class


class WorldSlice

Contains information on a slice of the world.

__init__(rect: Rect, dimension: str | None = None, heightmapTypes: Iterable[str] | None = None, retries: int = 0, timeout: Any = None, host: str = 'http://localhost:9000')

Load a world slice.

If heightmapTypes is None, all heightmaps are loaded.

property rect : Rect

The Rect of block coordinates this WorldSlice covers.

property chunkRect : Rect

The Rect of chunk coordinates this WorldSlice covers.

property yBegin : int

The minimum block y coordinate.

property yEnd : int

The maximum block y coordinate (exclusive); the “build height” plus one.

property ySize : int

The amount of blocks in the Y-axis.

property box : Box

The Box of block coordinates this WorldSlice covers.

property nbt : NBTFile

The parsed NBT data for the chunks of this WorldSlice.

Its structure is described in the GDMC HTTP interface API.

property heightmaps : dict[str, ndarray[tuple[int, ...], dtype[int64]]]

The heightmaps of this WorldSlice.

getChunkSectionPositionGlobal(blockPosition: Vec3iLike) ivec3

Returns the local position of the chunk section that contains the global blockPosition.

getChunkSectionPosition(blockPosition: Vec3iLike) ivec3

Returns the local position of the chunk section that contains the local blockPosition.

getBlockStateTagGlobal(position: Vec3iLike) TAG_Compound | None

Returns the block state compound tag at global position.

If position is not contained in this WorldSlice, returns None.

getBlockStateTag(position: Vec3iLike) TAG_Compound | None

Returns the block state compound tag at local position.

If position is not contained in this WorldSlice, returns None.

getBlockGlobal(position: Vec3iLike) Block

Returns the block at global position.

If position is not contained in this WorldSlice, returns Block(“minecraft:void_air”).

getBlock(position: Vec3iLike) Block

Returns the block at local position.

If position is not contained in this WorldSlice, returns Block(“minecraft:void_air”).

getBiomeGlobal(position: Vec3iLike) str

Returns the namespaced id of the biome at global position.

If position is not contained in this WorldSlice, returns an empty string.

Note that Minecraft stores biomes in groups of 4x4x4 blocks. This function returns the biome of position’s group.

getBiome(position: Vec3iLike) str

Returns the namespaced id of the biome at local position.

If position is not contained in this WorldSlice, returns an empty string.

Note that Minecraft stores biomes in groups of 4x4x4 blocks. This function returns the biome of position’s group.

getBiomeCountsInChunkGlobal(position: Vec3iLike) dict[str, int] | None

Returns a dict of biomes in the same chunk as the global position.

If position is not contained in this WorldSlice, returns None.

Minecraft stores biomes in groups of 4x4x4 blocks. The returned dict maps the namespaced id of a biome to the number of groups with that biome in the chunk.

getBiomeCountsInChunk(position: Vec3iLike) dict[str, int] | None

Returns a dict of biomes in the same chunk as the local position.

If position is not contained in this WorldSlice, returns None.

Minecraft stores biomes in groups of 4x4x4 blocks. The returned dict maps the namespaced id of a biome to the number of groups with that biome in the chunk.

getPrimaryBiomeInChunkGlobal(position: Vec3iLike) str | None

Returns the most prevalent biome in the same chunk as the global position.

If position is not contained in this WorldSlice, returns None.

getPrimaryBiomeInChunk(position: Vec3iLike) str | None

Returns the most prevalent biome in the same chunk as the local position.

If position is not contained in this WorldSlice, returns None.