Data2D: Read and write Data2D data

Data2DR Documentation

Read and write Data2D data

Description

Data2D data (tag 45) stores information about surface heights and biomes in a chunk. Data2D data is 768 bytes long and consists of a 256 int16s (heights) followed by 256 uint8s (biomes).

get_data2d_data() loads Data2D data from a bedrockdb. It will silently drop and keys not representing Data2D data.

get_data2d_value() loads Data2D data from a bedrockdb. It only supports loading a single value.

read_data2d_value decodes binary Data2D data.

put_data2d_data(), put_data2d_values(), and put_data2d_value() store Data2D data into a bedrockdb.

write_data2d_value encodes Data2D data into a raw vector.

Usage

get_data2d_data(db, x, z, dimension)

get_data2d_values(db, x, z, dimension)

get_data2d_value(db, x, z, dimension)

read_data2d_value(rawdata)

put_data2d_data(db, data)

put_data2d_values(db, x, z, dimension, height_maps, biome_maps)

put_data2d_value(db, x, z, dimension, height_map, biome_map)

write_data2d_value(height_map, biome_map)

Arguments

db

A bedrockdb object.

x, z, dimension

Chunk coordinates to extract data from. x can also be a character vector of db keys.

rawdata

A raw vector.

data

A named-vector of key-value pairs for Data2D data.

height_maps, biome_maps

Lists of height and biome data. Values will be recycled if necessary to match the number of keys to be written to. If biome_maps is missing, height_maps should be in the same format as returned by get_data2d_data().

height_map, biome_map

16x16 arrays containing height and biome data. Values will be recycled if necessary. If biome_map is missing, height-map should be a list a list() with both "height_map" and "biome_map" elements.

Value

get_data2d_data() returns a list of the of the values returned by get_data2d_value().

get_data2d_value() returns a list with components "height_map" and "biome_map".

Examples

heights <- matrix(63,16,16)
biomes <- matrix(1,16,16)
# Pass heights and biomes as separate parameters
dat <- write_data2d_value(heights, biomes)
# Pass them as a list.
obj <- list(height_map = heights, biome_map = biomes)
dat <- write_data2d_value(obj)
# Pass them as scalars
dat <- write_data2d_value(63, 1)

rbedrock documentation built on Oct. 7, 2023, 1:07 a.m.