Title: | Analysis and Manipulation of Data from Minecraft Bedrock Edition |
Version: | 0.4.1 |
Description: | Implements an interface to Minecraft (Bedrock Edition) worlds. Supports the analysis and management of these worlds and game saves. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
Language: | en-US |
LazyData: | true |
RoxygenNote: | 7.3.2 |
SystemRequirements: | cmake, zlib, GNU make |
NeedsCompilation: | yes |
Depends: | R (≥ 3.6.0) |
Imports: | R6, tibble, bit64, rappdirs, rlang, utils, digest |
Suggests: | spelling, zip, testthat, jsonlite, covr |
URL: | https://reedacartwright.github.io/rbedrock/, https://github.com/reedacartwright/rbedrock |
BugReports: | https://github.com/reedacartwright/rbedrock/issues |
Packaged: | 2025-08-24 21:32:32 UTC; reed |
Author: | Reed Cartwright |
Maintainer: | Reed Cartwright <racartwright@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-08-24 23:10:07 UTC |
rbedrock: Analysis and Manipulation of Data from Minecraft Bedrock Edition
Description
Implements an interface to Minecraft (Bedrock Edition) worlds. Supports the analysis and management of these worlds and game saves.
Details
rbedrock is currently under development.
Author(s)
Maintainer: Reed Cartwright racartwright@gmail.com (ORCID)
Other contributors:
Rich FitzJohn rich.fitzjohn@gmail.com [contributor]
Christian Stigen Larsen [contributor]
The LevelDB Authors [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/reedacartwright/rbedrock/issues
Read and write Actor Digest Data
Description
Actor digests store a list of all entities in a chunk; however they are not chunk data and use their own prefix. The key format for actor digest data is acdig:x:z:dimension.
get_acdig_data()
and get_acdig_value()
load ActorDigest
data from db
. get_acdig_value()
supports loading
only a single value.
put_acdig_data()
and put_acdig_value()
store ActorDigest data into db
.
read_acdig_value()
and write_acdig_value()
decode and encode
ActorDigest data respectively.
create_acdig_keys()
creates keys for ActorDigest data.
Usage
get_acdig_data(x, z, dimension, db = default_db())
get_acdig_value(x, z, dimension, db = default_db())
put_acdig_data(values, x, z, dimension, db = default_db())
put_acdig_value(value, x, z, dimension, db = default_db())
read_acdig_value(rawvalue)
write_acdig_value(value)
create_acdig_keys(x, z, dimension)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A list of character vectors.
If |
value |
A character vector. |
rawvalue |
A raw vector. |
Value
get_acdig_values()
returns a vector of actor keys.
get_acdig_data()
returns a named list of the of the values
returned by get_acdig_value()
.
See Also
Read and write Actor data
Description
After 1.18.30, the nbt data of each actor is saved independently in the database, using a key with a prefix and a 16-character storage key: 'actor:0123456789abcdef'. The keys of all actors in a chunk are saved in an ActorDigest record, with format acdig:x:z:dimension'.
Usage
get_actors_data(x, z, dimension, db = default_db())
get_actors_value(x, z, dimension, db = default_db())
put_actors_data(values, x, z, dimension, db = default_db())
put_actors_value(value, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A list of character vectors.
If |
value |
A list of nbt actors data |
Details
get_actors_value()
loads Actors data for a single chunk in db
.
get_actors_data()
loads Actors data from multiple chunks in db
.
put_actors_value()
and put_actors_data()
store one/multiple chunks
Actors data into db
and update the chunks' ActorDigests.
When storing Actors data, an actor's storage key will be recalculated from
the actor's UniqueID
. The actor's position and dimension are not verified
to be in the chunk it is assigned to.
See Also
Read and write Biomes data
Description
Biomes data is stored as the second map in the Data3D data (tag 43).
Usage
get_biomes_value(x, z, dimension, db = default_db(), return_names = TRUE)
get_biomes_data(x, z, dimension, db = default_db(), return_names = TRUE)
put_biomes_value(
value,
x,
z,
dimension,
db = default_db(),
missing_height = 0L
)
put_biomes_data(
values,
x,
z,
dimension,
db = default_db(),
missing_height = 0L
)
biome_id(value)
biome_name(value)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
return_names |
return biome names instead of biome ids. |
value |
An array of biome ids. |
missing_height |
if there is no existing height data, use this value for the chunk. |
values |
A (named) list of Biomes data values. If |
Details
-
get_biomes_value()
andget_biomes_data()
load Biomes data fromdb
.get_biomes_value()
loads data for a single chunk, andget_biomes_data()
loads data for multiple chunks. -
put_biomes_value()
andput_biomes_data()
store biomes data intodb
.
Value
get_biomes_value()
returns a Biomes data value.
get_biomes_data()
returns a named list of Biomes data values.
Biomes data values are 16x384x16 arrays containing biome data.
See Also
LegacyBiomes
Load and store BlockEntity NBT data
Description
BlockEntity data (tag 49) holds a list of NBT values for entity data associated with specific blocks.
Usage
get_block_entity_data(x, z, dimension, db = default_db())
get_block_entity_value(x, z, dimension, db = default_db())
put_block_entity_data(values, x, z, dimension, db = default_db())
put_block_entity_value(value, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of list of NBT objects. |
value |
A list of NBT objects. |
Details
-
get_block_entity_value()
andget_block_entity_data()
load BlockEntity data fromdb
.get_block_entity_value()
loads data for a single chunk, andget_block_entity_data()
loads data for multiple chunks. -
put_block_entity_value()
andput_block_entity_data()
store BlockEntity data for one or multiple chunks intodb
.
Value
get_block_entity_value()
returns a list of NBT objects.
get_block_entity_data()
returns a named list of lists of NBT objects.
Read and write Blocks data
Description
Blocks data stores information about blocks in a world and their properties. Blocks data is stored per-subchunk as SubChunkBlocks data. These functions are wrappers around a SubChunkBlocks functions to make it easy to save and load blocks for an entire chunk.
Usage
get_blocks_value(
x,
z,
dimension,
db = default_db(),
names_only = FALSE,
extra_block = !names_only
)
get_blocks_data(
x,
z,
dimension,
db = default_db(),
names_only = FALSE,
extra_block = !names_only
)
put_blocks_value(value, x, z, dimension, db = default_db())
put_blocks_data(values, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
names_only |
A logical scalar. Return only the names of the blocks, ignoring block states. |
extra_block |
A logical scalar. Append the extra block layer to the output (separated by ";"). This is mostly useful if you have waterlogged blocks. If the extra block is air, it will not be appended. |
value |
A 16x384x16 character array. |
values |
A (named) list of Blocks values. If |
Details
-
get_blocks_value()
andget_blocks_data()
load Blocks data fromdb
.get_blocks_value()
loads data for a single chunk, andget_blocks_data()
loads data for multiple chunks. -
put_blocks_value()
andput_blocks_data()
store Blocks data intodb
.
Value
get_blocks_value()
returns a Blocks value. get_blocks_data()
returns a named list of Blocks values.
See Also
SubChunkBlocks
Load and store Checksums data
Description
Checksums data (tag 59) holds checksums for several chunk records. These records are 2DMaps (tag 45), SubchunkBlocks (tag 47), BlockEntities (tag 49), and Entities (tag 50). Checksums are no longer used by the game.
-
get_checksums_value()
andget_checksums_data()
load Checksums data fromdb
.get_checksums_value()
loads data for a single chunk, andget_checksums_data()
loads data for multiple chunks. -
update_checksums_value()
andupdates_checksums_data()
recalculate Checksums data fromdb
and updatedb
. -
write_checksums_value()
encodes Checksums data into a raw vector.read_checksums_value()
decodes binary Checksums data.
Usage
get_checksums_value(x, z, dimension, db = default_db())
get_checksums_data(x, z, dimension, db = default_db())
update_checksums_value(x, z, dimension, db = default_db())
update_checksums_data(x, z, dimension, db = default_db())
read_checksums_value(rawvalue, key)
write_checksums_value(value)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
rawvalue |
A raw vector. |
key |
A key prefix. |
value |
A Checksums value. |
Value
get_checksums_value()
returns a Checksums value.
get_checksums_data()
returns a named list of Checksums values.
Checksums values are named character vectors.
Load and store raw chunk data
Description
-
get_chunk_value()
andget_chunk_data()
load raw chunk data fromdb
.get_chunk_value()
loads data for a single chunk, andget_chunk_data()
loads data for multiple chunks. -
put_chunk_value()
andput_chunk_data()
store chunk data for one or multiple chunks intodb
.
Usage
get_chunk_value(x, z, dimension, tag, subtag, db)
get_chunk_data(x, z, dimension, tag, subtag, db)
put_chunk_value(value, x, z, dimension, tag, subtag, db)
put_chunk_data(values, x, z, dimension, tag, subtag, db)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
A raw vector. |
values |
A list of raw vectors. |
Value
get_chunk_value()
returns a single raw vector.
get_chunk_data()
returns a named list of raw data.
Load and store NBT chunk data
Description
-
get_chunk_nbt_value()
andget_chunk_nbt_data()
load NBT data for a chunk fromdb
.get_chunk_nbt_value()
loads NBT data for a single chunk, andget_chunk_nbt_data()
loads data for multiple chunks. -
put_chunk_nbt_value()
andput_chunk_nbt_data()
store NBT data for one or multiple chunks intodb
.
Usage
get_chunk_nbt_data(x, z, dimension, tag, subtag, db)
get_chunk_nbt_value(x, z, dimension, tag, subtag, db)
put_chunk_nbt_data(values, x, z, dimension, tag, subtag, db)
put_chunk_nbt_value(value, x, z, dimension, tag, subtag, db)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of list of NBT objects. |
value |
A list of NBT objects. |
Value
get_chunk_nbt_value()
returns a list of NBT objects.
get_chunk_nbt_data()
returns a named list of lists of NBT objects.
Read and write chunk version data
Description
ChunkVersion data (tag 44) stores the chunk version number for a chunk.
Usage
get_chunk_version_value(x, z, dimension, db = default_db())
get_chunk_version_data(x, z, dimension, db = default_db())
put_chunk_version_value(value, x, z, dimension, db = default_db())
put_chunk_version_data(values, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
An integer |
values |
A (named) vector of ChunkVersion values. If |
Details
-
get_chunk_version_value()
andget_chunk_version_data()
load ChunkVersion data fromdb
.get_chunk_version_value()
loads data for a single chunk, andget_chunk_version_data()
loads data for multiple chunks. -
put_chunk_version_value()
andput_chunk_version_data()
store ChunkVersion data intodb
.
Value
get_chunk_version_value()
returns a ChunkVersion data
value. get_chunk_version_data()
returns a named vector of
ChunkVersion data values.
See Also
ChunkVersion
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). The game no longer uses it after 1.18.
-
get_data2d_value()
andget_data2d_data()
load Data2D data fromdb
.get_data2d_value()
loads data for a single chunk, andget_data2d_data()
loads data for multiple chunks. -
put_data2d_value()
andput_data2d_data()
store Data2D data intodb
. -
write_data2d_value()
encodes Data2D data into a raw vector.read_data2d_value()
decodes binary Data2D data.
Usage
get_data2d_data(x, z, dimension, db = default_db())
get_data2d_value(x, z, dimension, db = default_db())
put_data2d_data(values, x, z, dimension, db = default_db())
put_data2d_value(value, x, z, dimension, db = default_db())
read_data2d_value(rawvalue)
write_data2d_value(value)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of Data2D values. If |
value |
A Data2D value. |
rawvalue |
A raw vector. |
Value
get_data2d_value()
returns a Data2D value. get_data2d_data()
returns a named list of Data2D values. Data2D values are lists containing
two elements. The height_map
element is a 16x16 matrix containing height
data. The biome_map
element is a 16x16 matrix containing biome data.
See Also
Data3D
Read and write Data3D data
Description
Data3D data (tag 43) stores information about surface heights and biomes in a chunk.
Usage
get_data3d_value(x, z, dimension, db = default_db())
get_data3d_data(x, z, dimension, db = default_db())
put_data3d_value(value, x, z, dimension, db = default_db())
put_data3d_data(values, x, z, dimension, db = default_db())
read_data3d_value(rawvalue)
write_data3d_value(value)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
A Data3D value. |
values |
A (named) list of Data3D values. If |
rawvalue |
A raw vector. |
Details
-
get_data3d_value()
andget_data3d_data()
load Data3D data fromdb
.get_data3d_value()
loads data for a single chunk, andget_data3d_data()
loads data for multiple chunks. -
put_data3d_value()
andput_data3d_data()
store Data3D data intodb
. -
write_data3d_value()
encodes Data3D data into a raw vector.read_data3d_value()
decodes binary Data3D data.
Value
get_data3d_value()
returns a Data3D value. get_data3d_data()
returns a named list of Data3D values. Data3D values are lists containing
two elements. The height_map
element is a 16x16 matrix containing height
data. The biome_map
element is a 16x384x16 array containing biome data.
See Also
Data2D
Load and store Entity NBT data
Description
Entity data (tag 50) holds a list of NBT values for mobs and other entities in the game. After 1.18.30, entity data was migrated to a new actor digest format and no longer saved with chunk data.
-
get_entity_value()
andget_entity_data()
load Entity data fromdb
.get_entity_value()
loads data for a single chunk, andget_entity_data()
loads data for multiple chunks. -
put_entity_value()
andput_entity_data()
store Entity data for one or multiple chunks intodb
.
Usage
get_entity_data(x, z, dimension, db = default_db())
get_entity_value(x, z, dimension, db = default_db())
put_entity_data(values, x, z, dimension, db = default_db())
put_entity_value(value, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of list of NBT objects. |
value |
A list of NBT objects. |
Value
get_entity_value()
returns a list of NBT objects.
get_entity_data()
returns a named list of lists of NBT objects.
Load and store FinalizedState data
Description
FinalizedState data (tag 54) holds a number which indicates a chunk's state of generation.
Usage
get_finalized_state_value(x, z, dimension, db = default_db())
get_finalized_state_data(x, z, dimension, db = default_db())
put_finalized_state_value(value, x, z, dimension, db = default_db())
put_finalized_state_data(values, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
An integer |
values |
A (named) vector of FinalizedState values. If |
Details
FinalizedState data contains the following information.
Value | Name | Description |
0 | NeedsInstaticking | Chunk needs to be ticked |
1 | NeedsPopulation | Chunk needs to be populated with mobs |
2 | Done | Chunk generation is fully complete |
-
get_finalized_state_value()
andget_finalized_state_data()
load FinalizedState data fromdb
.get_finalized_state_value()
loads data for a single chunk, andget_finalized_state_data()
loads data for multiple chunks. -
put_finalized_state_value()
andput_finalized_state_data()
store FinalizedState data intodb
.
Value
get_finalized_state_value()
returns a ChunkVersion data
value. get_finalized_state_data()
returns a named vector of
FinalizedState data values.
Read and write HardcodedSpawnArea (HSA) data
Description
HardcodedSpawnArea (HSA) data (tag 57) stores information about any structure spawning locations in a chunk. An HSA is defined by a bounding box that specifies the location of an HSA in a chunk and a tag that specifies the type:
Value | Name |
1 | NetherFortress |
2 | SwampHut |
3 | OceanMonument |
4 | Removed Cat HSA |
5 | PillagerOutpost |
6 | Removed Cat HSA |
As of version 1.21.10, HSA data is no longer saved to the world db.
-
get_hsa_value()
andget_hsa_data()
load HardcodedSpawnArea data fromdb
.get_hsa_value()
loads data for a single chunk, andget_hsa_data()
loads data for multiple chunks. -
put_hsa_value()
andput_hsa_data()
store HardcodedSpawnArea data intodb
.
Usage
get_hsa_value(x, z, dimension, db = default_db())
get_hsa_data(x, z, dimension, db = default_db())
put_hsa_value(value, x, z, dimension, db = default_db())
put_hsa_data(values, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
A HardcodedSpawnArea value |
values |
A (named) vector of HardcodedSpawnArea values. If |
Value
get_hsa_value()
returns a HardcodedSpawnArea data value.
get_hsa_data()
returns a named vector of HardcodedSpawnArea data values.
HardcodedSpawnArea data values are integer matrices.
Read and write legacy biomes data
Description
Legacy Biomes data is stored as the second map in the Data2D data (tag 45).
-
get_legacy_biomes_value()
andget_legacy_biomes_data()
load legacy biomes data fromdb
.get_legacy_biomes_value()
loads data for a single chunk, andget_legacy_biomes_data()
loads data for multiple chunks. -
put_legacy_biomes_value()
andput_legacy_biomes_data()
store legacy biomes data intodb
.
Usage
get_legacy_biomes_value(
x,
z,
dimension,
db = default_db(),
return_names = TRUE
)
get_legacy_biomes_data(x, z, dimension, db = default_db(), return_names = TRUE)
put_legacy_biomes_value(
value,
x,
z,
dimension,
db = default_db(),
missing_height = 0L
)
put_legacy_biomes_data(
values,
x,
z,
dimension,
db = default_db(),
missing_height = 0L
)
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
return_names |
return biome names instead of biome ids. |
value |
A 16x16 matrix of biome ids. |
missing_height |
if there is no existing height data, use this value for the chunk. |
values |
A (named) list of LegacyBiomes values. If |
Value
get_legacy_biomes_value()
returns a legacy biomes data value.
get_legacy_biomes_data()
returns a named list of legacy biomes data values.
Legacy biomes data values are 16x16 matrices containing biome data.
See Also
Biomes
Read and write legacy chunk version data
Description
LegacyChunkVersion data (tag 118) stores the chunk version number for a chunk. In Minecraft version 1.16.100, chunk version data was moved from tag 118 to tag 44.
-
get_legacy_chunk_version_value()
andget_legacy_chunk_version_data()
load LegacyChunkVersion data fromdb
.get_legacy_chunk_version_value()
loads data for a single chunk, andget_legacy_chunk_version_data()
loads data for multiple chunks. -
put_legacy_chunk_version_value()
andput_legacy_chunk_version_data()
store LegacyChunkVersion data intodb
.
Usage
get_legacy_chunk_version_value(x, z, dimension, db = default_db())
get_legacy_chunk_version_data(x, z, dimension, db = default_db())
put_legacy_chunk_version_value(value, x, z, dimension, db = default_db())
put_legacy_chunk_version_data(values, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
An integer |
values |
A (named) vector of LegacyChunkVersion values. If |
Value
get_legacy_chunk_version_value()
returns a LegacyChunkVersion data
value. get_legacy_chunk_version_data()
returns a named vector of
LegacyChunkVersion data values.
See Also
ChunkVersion
Load and store PendingTicks NBT data
Description
PendingTicks data (tag 51) holds a list of NBT values for pending ticks.
Usage
get_pending_ticks_data(x, z, dimension, db = default_db())
get_pending_ticks_value(x, z, dimension, db = default_db())
put_pending_ticks_data(values, x, z, dimension, db = default_db())
put_pending_ticks_value(value, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of list of NBT objects. |
value |
A list of NBT objects. |
Details
-
get_pending_ticks_value()
andget_pending_ticks_data()
load PendingTicks data fromdb
.get_pending_ticks_value()
loads data for a single chunk, andget_pending_ticks_data()
loads data for multiple chunks. -
put_pending_ticks_value()
andput_pending_ticks_data()
store PendingTicks data for one or multiple chunks intodb
.
Value
get_pending_ticks_value()
returns a list of NBT objects.
get_pending_ticks_data()
returns a named list of lists of NBT objects.
Load and store RandomTicks NBT data
Description
RandomTicks data (tag 59) holds a list of NBT values for random ticks.
Usage
get_random_ticks_data(x, z, dimension, db = default_db())
get_random_ticks_value(x, z, dimension, db = default_db())
put_random_ticks_data(values, x, z, dimension, db = default_db())
put_random_ticks_value(value, x, z, dimension, db = default_db())
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
values |
A (named) list of list of NBT objects. |
value |
A list of NBT objects. |
Details
-
get_random_ticks_value()
andget_random_ticks_data()
load RandomTicks data fromdb
.get_random_ticks_value()
loads data for a single chunk, andget_random_ticks_data()
loads data for multiple chunks. -
put_random_ticks_value()
andput_random_ticks_data()
store RandomTicks data for one or multiple chunks intodb
.
Value
get_random_ticks_value()
returns a list of NBT objects.
get_random_ticks_data()
returns a named list of lists of NBT objects.
Load and store SubChunkBlocks data
Description
SubChunkBlocks data (tag 47) stores information about the blocks in a world. Each chunk is divided into multiple 16x16x16 subchunks, and the blocks for each subchunk are stored separately. Blocks are stored per subchunk in a palette-based format. Block storage is separated into multiple layers where each layer has its own block palette and block ids. In practices subchunks have either one or two layers, and the extra layer is most-often used to store water for water-logged blocks.
Usage
get_subchunk_blocks_value(x, z, dimension, subchunk, db = default_db())
get_subchunk_blocks_data(x, z, dimension, subchunk, db = default_db())
put_subchunk_blocks_value(
value,
x,
z,
dimension,
subchunk,
db = default_db(),
version = 9L
)
put_subchunk_blocks_data(
values,
x,
z,
dimension,
subchunk,
db = default_db(),
version = 9L
)
read_subchunk_blocks_value(rawvalue, subchunk_position = NA_integer_)
write_subchunk_blocks_value(value, subchunk_position, version = 9L)
subchunk_blocks_value_as_array(
value,
names_only = FALSE,
extra_block = !names_only
)
subchunk_blocks_array_as_value(r)
subchunk_origins(keys)
subchunk_coords(ind, origins = subchunk_origins(names(ind)))
Arguments
x , z , dimension |
Chunk coordinates to extract data from.
|
subchunk |
Subchunk indexes |
db |
A bedrockdb object. |
value |
A SubChunkBlocks data value |
version |
Which format of subchunk data to use |
values |
A (named) list of SubChunkBlocks data values. If |
rawvalue |
A raw vector |
subchunk_position |
Optional, an integer. When reading a value, it will be used if the value's position attribute is missing. When writing a value, it will be used in place of the value's position attribute. |
names_only |
A logical scalar. Return only the names of the blocks, ignoring block states. |
extra_block |
A logical scalar. Append the extra block layer to the output (separated by ";"). This is mostly useful if you have waterlogged blocks. If the extra block is air, it will not be appended. |
r |
A character array |
keys |
A character vector of keys. |
ind |
Numeric vector or a named list of numeric vectors containing indexes for blocks in a subchunk. |
origins |
A matrix of subchunk origins. |
Details
The format description can be found at https://gist.github.com/Tomcc/a96af509e275b1af483b25c543cfbf37.
-
get_subchunk_blocks_value()
andget_subchunk_blocks_data()
load SubChunkBlocks data fromdb
.get_subchunk_blocks_value()
loads data for a single subchunk, andget_subchunk_blocks_data()
loads data for multiple subchunks. -
put_subchunk_blocks_value()
andput_subchunk_blocks_data()
store SubChunkBlocks data intodb
. -
write_subchunk_blocks_value()
encodes SubChunkBlocks data into a raw vector.read_subchunk_blocks_value()
decodes binary SubChunkBlocks data. -
subchunk_blocks_value_as_array()
converts SubChunkBlocks data into a character array. -
subchunk_origins()
returns a matrix containing the block coordinate of the lower NW corner of subchunk keys. -
subchunk_coords()
determines the block coordinates of blocks based on their array indexes and their subchunk origins.
Value
get_subchunk_blocks_value()
returns a SubChunkBlocks data value.
get_biomes_data()
returns a named list of SubChunkBlocks data values.
Open a LevelDB Database
Description
Create a leveldb
object, to interact with a LevelDB
database.
Usage
bedrock_leveldb_open(
path,
create_if_missing = NULL,
error_if_exists = NULL,
paranoid_checks = NULL,
write_buffer_size = NULL,
max_open_files = NULL,
block_size = NULL,
cache_capacity = NULL,
bloom_filter_bits_per_key = NULL,
compression_level = NULL
)
Arguments
path |
The path to the database, as stored on the filesystem.
This will create a directory at this path if one does not
exist (and if |
create_if_missing |
Create the database if one does not
already exist at |
error_if_exists |
Throw an error if the database already
exists at |
paranoid_checks |
If |
write_buffer_size |
Amount of data (in bytes) to build up in memory (backed by an unsorted log on disk) before converting to a sorted on-disk file. Larger values increase performance, especially during bulk loads. Up to two write buffers may be held in memory at the same time, so you may wish to adjust this parameter to control memory usage. Also, a larger write buffer will result in a longer recovery time the next time the database is opened. |
max_open_files |
Number of files that can be used by the database. You may need to increase this if your database has a large working set (budget one open file per 2MB of working set). (LevelDB default: 1000). |
block_size |
The approximate size of user data packed per block (user data is stored in a set of blocks, and a block is the unit of reading from disk). The block size here corresponds to uncompressed data; the actual size of the unit read from disk may be smaller if compression is enabled (LevelDB default: 4K) |
cache_capacity |
The size of the cache to use. If
non- |
bloom_filter_bits_per_key |
If non-NULL, this sets up a
'filter policy' to reduce disk reads. A good value for
bits_per_key is 10, which yields a filter with ~ 1% false
positive rate. Further information from the LevelDB headers
(filter_policy.h) "This object is responsible for
creating a small filter from a set of keys. These filters are
stored in leveldb and are consulted automatically by leveldb to
decide whether or not to read some information from disk. In
many cases, a filter can cut down the number of disk seeks form
a handful to a single disk seek per |
Details
For all optional arguments (i.e., all but path
) a value of
NULL
means that we use the LevelDB
default; the
LevelDB default of each argument is indicated in the argument
documentation.
This function returns an 'R6' class with a number of methods.
Author(s)
Rich FitzJohn
Random Number Generation for Minecraft
Description
Bedrock Edition's central random number algorithm is MT19937. However, R's MT19937 code is not compatible with Bedrock's. These routines provide an API that is compatible with Bedrock's.
bedrock_random_seed()
seeds the random number generator.
bedrock_random_state()
returns the current state of the random number
generator as a raw vector.
bedrock_random_get_uint()
returns a 32-bit random integer.
Default range is [0, 2^32-1]
.
bedrock_random_get_int()
returns a 31-bit random integer.
Default range is [0, 2^31-1]
.
bedrock_random_get_float()
returns a random real number.
Default range is [0.0, 1.0)
.
bedrock_random_get_double()
returns a random real number
Default range is [0.0, 1.0)
.
Usage
bedrock_random_seed(value)
bedrock_random_state(new_state = NULL)
bedrock_random_get_uint(n, max)
bedrock_random_get_int(n, min, max)
bedrock_random_get_float(n, min, max)
bedrock_random_get_double(n)
Arguments
value |
a scalar integer |
new_state |
a raw vector |
n |
number of observations. |
min , max |
lower and upper limits of the distribution. Must be finite.
If only one is specified, it is taken as |
Examples
# seed the global random number generator
bedrock_random_seed(5490L)
# save and restore rng state
saved_state <- bedrock_random_state()
bedrock_random_get_uint(10)
bedrock_random_state(saved_state)
bedrock_random_get_uint(10)
Random Number Seeds for Minecraft
Description
Minecraft uses several different kind of seeds during world generation and gameplay.
Usage
bedrock_random_create_seed(x, z, a, b, salt, type)
Arguments
x , z |
chunk coordinates |
a , b |
seed parameters |
salt |
seed parameter |
type |
which seed type to use |
Details
bedrock_random_create_seed()
constructs a seed using the formulas
type 1: x*a ^ z*b ^ salt
, type 2: x*a + z*b + salt
, and type 3:
x*a + z*b ^ salt
.
Examples
# identify slime chunks
g <- expand.grid(x=1:10, z=1:10)
is_slime_chunk <- mapply(g$x, g$z, FUN = function(x,z) {
seed <- bedrock_random_create_seed(x,z,0x1f1f1f1f,1,0,type=1)
bedrock_random_seed(seed)
bedrock_random_get_uint(1,10) == 0
})
Open a Bedrock Edition world for reading and writing.
Description
bedrockdb
opens a handle to a leveldb database that contains
save-game data for a Bedrock Edition world. On success, it returns
an R6 class of type 'bedrockdb' that can be used directly for
low-level reading and writing access to the db or can be passed to
higher-level functions. The handle to the database can be closed
by passing it to close
.
Usage
bedrockdb(
path,
create_if_missing = FALSE,
error_if_exists = NULL,
paranoid_checks = NULL,
write_buffer_size = 4194304L,
max_open_files = NULL,
block_size = 163840L,
cache_capacity = 83886080L,
bloom_filter_bits_per_key = 10L,
compression_level = -1L
)
## S3 method for class 'bedrockdb'
close(con, compact = FALSE, ...)
is_bedrockdb(x)
Arguments
path |
The path to a world folder. If the path does not exist, it is assumed to be the base name of a world folder in the local minecraftWorlds directory. |
create_if_missing |
Create world database if it doesn't exist. |
error_if_exists |
Raise an error if the world database already exists. |
paranoid_checks |
Internal leveldb option |
write_buffer_size |
Internal leveldb option |
max_open_files |
Internal leveldb option |
block_size |
Internal leveldb option |
cache_capacity |
Internal leveldb option |
bloom_filter_bits_per_key |
Internal leveldb option |
compression_level |
Internal leveldb option |
con |
An database object created by bedrockdb. |
compact |
Compact database before closing. |
... |
arguments passed to or from other methods. |
x |
An object. |
Value
On success, bedrockdb
returns an R6 class of type 'bedrockdb'.
Examples
# open an example works and get all keys
dbpath <- rbedrock_example_world("example1.mcworld")
db <- bedrockdb(dbpath)
keys <- get_keys()
close(db)
## Not run:
# open a world in the minecraftWorlds folder using a world id.
db <- bedrockdb("lrkkYFpUABA=")
# do something with db ...
close(db)
# open a world using absolute path
db <- bedrockdb("C:\\\\minecraftWorlds\\\\my_world")
# do something with db ...
close(db)
## End(Not run)
Bedrock biome data
Description
Information about biomes used in Bedrock edition. Generated from the PyMCTranslate project. Colors are generated from the cubiomes project.
Usage
biome_df
Format
A data.frame with 87 rows and 5 columns.
- bedrock_id
The numeric id of the biome.
- bedrock_name
The name of the biome.
- java_name
The name of the equivalent biome in Java edition.
- universal_name
The universal name used for the biome in Amulet.
- color
The color used when mapping biomes.
Source
Convert block data from nbt format to a string
Description
Block data is stored in nbt format, which includes a block's name and
properties. blocks_str()
converts the nbt data into strings with the
following format: blockname@prop1=val1@prop2=val2
. Blocks can have
zero or more properties. blocks_nbt()
does the inverse operation.
Usage
blocks_str(x, names_only = FALSE)
blocks_nbt(x)
Arguments
x |
block data, either as a list of nbt values or a vector of strings. |
names_only |
A logical scalar. Return only the names of the blocks, ignoring block properties. |
Convert between key types.
Description
rbedrock represents database keys two different ways. chrkeys
are a
human-readable format understood by most functions. rawkeys
are used
internally, by the methods of bedrockdb
objects and bedrock_leveldb_*
functions.
Usage
chrkeys_to_rawkeys(keys)
chrkeys_to_rawkeys_1(keys)
rawkeys_to_chrkeys(keys)
Arguments
keys |
a character vector of chrkeys or a list or rawkeys |
Value
chrkeys_to_rawkeys()
returns a list of raw vectors.
`rawkeys_to_chrkeys()` returns a character vector. `chrkeys_to_rawkeys_1()` returns a raw vector.
Extract or replace chunk blocks from an array
Description
Convenience wrappers around [
to extract or replace blocks from an array
based on block coordinates.
Usage
chunk_blocks(x, ..., drop = TRUE, origin = chunk_origin(x))
chunk_blocks(x, ..., origin = chunk_origin(x)) <- value
Arguments
x |
Object from which to extract element(s) or in which to replace element(s). |
... |
block coordinates specifying elements to extract or replace. Can be numeric, logical, or missing. If numeric, the coordinates will be mapped to indices unless there is a single, non-matrix argument. |
drop |
if |
origin |
the origin of the chunk array, used for mapping coordinates to indices |
value |
An array-like R object of similar class as x |
Read and manipulate chunk keys
Description
Chunk keys are keys to chunk data. A chunk key has a format which indicates
the chunk it holds data for and the type of data it holds. This format is
either chunk:x:z:d:t
or chunk:x:z:d:t:s
, where x
and z
indicates the
coordinates of the chunk in chunk space, d
indicates the dimension of
the chunk, and t
and s
indicate the tag and subtag of the chunk.
parse_chunk_keys()
splits chunk keys into their individual elements and
returns a table with the results.
create_chunk_keys()
returns a vector of chunk keys formed from its
arguments.
chunk_positions()
returns a matrix containing the chunk coordinates of
keys.
chunk_origins()
returns a matrix containing the block coordinate of the NW
corner of keys.
chunk_tag_str()
and chunk_tag_int()
convert between integer and character
representations of chunk tags.
Usage
parse_chunk_keys(keys)
create_chunk_keys(x, z, dimension, tag, subtag)
chunk_positions(keys)
chunk_origins(keys)
chunk_tag_str(tags)
chunk_tag_int(tags)
Arguments
keys |
A character vector of database keys. |
x |
Chunk x-coordinate. |
z |
Chunk z-coordinate. |
dimension |
Dimension. |
tag |
The type of chunk data. |
subtag |
The subchunk the key refers to (Only used for tag 47). |
tags |
a vector |
Examples
parse_chunk_keys("chunk:0:0:0:44")
parse_chunk_keys("chunk:0:0:0:47:1")
create_chunk_keys(0, 0, 0, 47, 1)
Get or set the coordinates of the origin of a chunk
Description
Get or set the coordinates of the origin of a chunk
Usage
chunk_origin(x)
chunk_origin(x) <- value
Arguments
x |
an array of block data |
value |
an integer vector |
Compact a world database.
Description
Compact a world database.
Usage
compact_world(db)
Get/set the default db connection.
Description
The default db is the db connection that rbedrock uses by default. It defaults to the most recently opened db, but can also be set by the user.
Usage
default_db(db, check = TRUE)
with_db(db, code, close = is.character(db))
local_db(db, .local_envir = parent.frame(), close = is.character(db))
Arguments
db |
For |
check |
Check the validity of |
code |
Code to execute in the temporary environment. |
close |
Close |
.local_envir |
The environment to use for scoping. |
Details
Invoking default_db()
returns the current default connection or the most
recently opened one. Invoking default_db(db)
updates the current default
and returns the previous set value. default_db(NULL)
can be used to unset
the default db and revert to the last opened one. Closing db
will unset
it as the default db as well.
with_db()
and local_db()
temporarily change the default db.
Value
For default_db()
, the calculated value of the default db.
For default_db(db)
, the previously manually set value of default_db()
.
For with_db(db, code)
, the result of evaluating code
with db
as the
default db
. For local_db(db)
, the value of db
.
See Also
Examples
dbpath <- rbedrock_example_world("example1.mcworld")
dbz <- bedrockdb(dbpath)
default_db(dbz) # set default
default_db() # returns dbz
default_db(NULL) # unset default
#cleanup
close(dbz)
with_db(dbpath, length(get_keys))
db <- local_db(dbpath)
length(get_keys())
close(db)
unlink(dbpath, recursive = TRUE)
Remove values from a bedrockdb.
Description
Remove values from a bedrockdb.
Usage
delete_values(
keys,
db = default_db(),
report = FALSE,
readoptions = NULL,
writeoptions = NULL
)
Arguments
keys |
A character vector of keys. |
db |
A |
report |
A logical indicating whether to generate a report on deleted keys |
readoptions |
A |
writeoptions |
A |
Value
If report == TRUE
, a logical vector indicating which keys were
deleted.
Get a list of keys stored in a bedrockdb.
Description
Get a list of keys stored in a bedrockdb.
Usage
get_keys(prefix = NULL, db = default_db(), readoptions = NULL)
Arguments
prefix |
A string specifying chunk prefix or string prefix. |
db |
A |
readoptions |
A |
Value
A vector containing all the keys found in the bedrockdb.
If prefix
is specified, this vector will be filtered for
based on the specified prefix.
Read and Write NBT Data
Description
The Named Binary Tag (NBT) format is used by Minecraft for various data types.
Usage
get_nbt_data(keys, db = default_db(), readoptions = NULL, simplify = TRUE)
get_nbt_value(key, db = default_db(), readoptions = NULL, simplify = TRUE)
put_nbt_data(values, keys, db = default_db(), writeoptions = NULL)
put_nbt_value(value, key, db = default_db(), writeoptions = NULL)
read_nbt(
rawvalue,
format = c("little", "big", "network", "network_big"),
simplify = TRUE
)
read_nbt_data(
rawdata,
format = c("little", "big", "network", "network_big"),
simplify = TRUE
)
write_nbt(value, format = c("little", "big", "network", "network_big"))
write_nbt_data(values, format = c("little", "big", "network", "network_big"))
Arguments
keys |
A character vector of keys |
db |
A |
readoptions |
A |
simplify |
If TRUE, simplifies a list containing a single unnamed nbt value. |
key |
A single key |
values |
A list of values. Optionally named. |
writeoptions |
A |
value |
An nbt object or a list of nbt objects |
rawvalue |
A |
format |
A character string specifying which binary NBT format to use. |
rawdata |
A list of |
Details
get_nbt_data()
and get_nbt_value()
load nbt-formatted data from db
and parses it.
put_nbt_data()
and put_nbt_value()
store nbt data into db
in binary
form.
read_nbt()
reads NBT data from a raw
vector.
read_nbt_data()
calls read_nbt()
on each element of a list.
write_nbt()
encodes NBT data into a raw
vector.
write_nbt_data()
calls write_nbt()
on each element of a list.
Read values stored in a bedrockdb.
Description
Read values stored in a bedrockdb.
Usage
key_prefix(prefix)
starts_with(prefix)
get_data(keys, db = default_db(), readoptions = NULL)
get_value(key, db = default_db(), readoptions = NULL)
has_values(keys, db = default_db(), readoptions = NULL)
Arguments
prefix |
A string specifying key prefix |
keys |
A character vector of keys |
db |
A |
readoptions |
A |
key |
A single key |
Value
get_data()returns a named-list of raw vectors.
get_value()' returns a raw vector.
has_values()
returns a logical vector.
Locate the coordinates of blocks in a chunk
Description
Locate the coordinates of blocks in a chunk
Usage
locate_blocks(blocks, pattern, negate = FALSE)
Arguments
blocks |
A character array containing block data. |
pattern |
The pattern to look for. Passed to base::grep. |
negate |
If |
Examples
dbpath <- rbedrock_example_world("example1.mcworld")
db <- bedrockdb(dbpath)
blocks <- get_blocks_value(db, x=37, z=10, dimension=0)
locate_blocks(blocks, "ore")
close(db)
Utilities for working with Minecraft world folders.
Description
world_dir_path()
returns the path to the minecraftWorlds
directory. Use
options(rbedrock.worlds_dir_path = "custom/path")
to customize the path
as needed.
list_worlds()
returns a data.frame()
containing information about
Minecraft saved games.
create_world()
creates a new Minecraft world.
export_world()
exports a world to an archive file.
Usage
worlds_dir_path(force_default = FALSE)
list_worlds(worlds_dir = worlds_dir_path())
create_world(id = NULL, ..., worlds_dir = worlds_dir_path())
export_world(id, file, worlds_dir = worlds_dir_path(), replace = FALSE)
import_world(file, id = NULL, ..., worlds_dir = worlds_dir_path())
get_world_path(id, worlds_dir = worlds_dir_path())
Arguments
force_default |
If |
worlds_dir |
The path of a |
id |
The path to a world folder. If the path is not absolute or does not
exist, it is assumed to be the base name of a world folder in |
... |
Arguments to customize |
file |
The path to an mcworld file. If exporting, it will be created. If importing, it will be extracted. |
replace |
If |
Examples
## Not run:
create_world(LevelName = "My World", RandomSeed = 10)
## End(Not run)
Create an NBT value
Description
The Named Binary Tag (NBT) format is used by Minecraft for various data types. An NBT value holds a 'payload' of data and a 'tag' indicating the type of data held.
Usage
unnbt(x)
nbt_compound(...)
nbt_byte(x)
nbt_byte_array(x)
nbt_byte_list(x)
nbt_byte_array_list(x)
nbt_short(x)
nbt_short_list(x)
nbt_int(x)
nbt_int_array(x)
nbt_int_list(x)
nbt_int_array_list(x)
nbt_float(x)
nbt_float_list(x)
nbt_double(x)
nbt_double_list(x)
nbt_long(x)
nbt_long_array(x)
nbt_long_list(x)
nbt_long_array_list(x)
nbt_string(x)
nbt_raw_string(x)
nbt_string_list(x)
nbt_raw_string_list(x)
nbt_empty_list(x = list())
nbt_compound_list(x)
nbt_nested_list(x)
Arguments
x |
An nbt payload. |
... |
NBT objects, possibly named. |
Details
-
nbt_*()
family of functions create nbt data types. -
unnbt()
recursively strips NBT metadata from an NBT value.
Create a list of nbt objects.
Description
Create a list of nbt objects.
Usage
nbt_list_of(...)
Arguments
... |
NBT objects, possibly named. |
Write values to a bedrockdb.
Description
Write values to a bedrockdb.
Usage
put_data(values, keys, db = default_db(), writeoptions = NULL)
put_value(value, key, db = default_db(), writeoptions = NULL)
Arguments
values |
A list of raw values. |
keys |
A character vector of keys. |
db |
A |
writeoptions |
A |
value |
A raw vector that contains the information to be written. |
key |
A key that will be used to store data. |
Value
An invisible copy of db
.
Cast a value to a specific type
Description
This is a helper function used (mostly) for modifying NBT values.
Usage
rac_cast(x, to, ..., x_arg = "x")
Arguments
x |
Value to cast |
to |
Type to cast to |
... |
Currently unused. |
x_arg |
Argument name for |
Object type as a string
Description
rac_type_full()
displays the fill type of the object.
rac_type_abbr()
provides an abbreviated description.
Usage
rac_type_full(x)
rac_type_abbr(x)
Arguments
x |
An object. |
Get path to rbedrock example
Description
rbedrock comes bundled with a number of sample files in its inst/extdata
directory. This function make them easy to access.
Usage
rbedrock_example(path = NULL)
rbedrock_example_world(path)
Arguments
path |
Name of file or directory. If |
Examples
rbedrock_example()
rbedrock_example("example1.mcworld")
rbedrock_example_world("example1.mcworld")
Read and write data from a world's level.dat file.
Description
Read and write data from a world's level.dat file.
Usage
read_leveldat(path)
write_leveldat(object, path, version = 8L)
Arguments
path |
The path to a world folder. If the path does not exist, it is assumed to be the base name of a world folder in the local minecraftWorlds directory. |
object |
NBT data to be written to level.dat. |
version |
The level.dat format version for the file header. |
Value
read_leveldat
returns nbt data.
write_leveldat
returns a copy of the data written.
Examples
# Fix level.dat after opening a world in creative.
dbpath <- rbedrock_example_world("example1.mcworld")
dat <- read_leveldat(dbpath)
dat$hasBeenLoadedInCreative <- FALSE
write_leveldat(dat, dbpath)
Try to repair a world database.
Description
Try to repair a world database.
Usage
repair_world(id)
Raw Named Binary Tag Format
Description
rnbt
is a recursive, intermediate data structure that closely
resembles how NBT data is encoded.
Usage
read_rnbt(rawvalue, format = c("little", "big", "network", "network_big"))
read_rnbt_once(rawvalue, format = c("little", "big", "network", "network_big"))
write_rnbt(x, format = c("little", "big", "network", "network_big"))
from_rnbt(x)
to_rnbt(x)
Arguments
rawvalue |
A |
format |
A character string specifying which binary NBT format to use. |
x |
An object |
Details
-
read_rnbt()
converts araw
vector tornbt
data. -
write_rnbt()
convertsrnbt
data to araw
vector -
from_rnbt()
convertsrnbt
data tonbt
data. -
to_rnbt()
convertsnbt
data tornbt
data.
Calculate a player-based simulation area
Description
Calculate a player-based simulation area
Usage
simulation_area(sim_distance, x = 0, z = 0)
Arguments
sim_distance |
A sim distance setting |
x , z |
Chunk coordinates where a player is standing |
Value
A data.frame
containing the chunk coordinates in the simulation
area.
Calculate a player-based spawning area
Description
Calculate a player-based spawning area
Usage
spawning_area(sim_distance, x = 0, z = 0)
Arguments
sim_distance |
A sim distance setting |
x , z |
Chunk coordinates where a player is standing (can be fractional) |
Value
A data.frame
containing the chunk coordinates in the spawning area.
Convert an nbt value to an rnbt value
Description
This is a helper function used to convert from nbt values to rnbt data.
Usage
to_rnbt_value(x, ...)
Arguments
x |
Value to cast |
... |
Currently unused. |
Bedrock block data
Description
Information about blocks used in Bedrock edition. Generated from the PyMCTranslate project.
Usage
vanilla_block_states_df
vanilla_block_list
vanilla_block_property_type_list
Format
vanilla_block_states_df
A data.frame in long-format with 1131 rows and 5 columns. Block data version is 18168865.
- name
Block name.
- property
Property name.
- type
Property type.
- default
Default value.
- allowed
Allowed values.
vanilla_block_list
List of blocks names. Includes blocks without properties, which don't show up in vanilla_block_states_df.
vanilla_block_property_type_list
List of properties (names) and their types (values).