| Title: | 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. |
| Authors: | Reed Cartwright [aut, cre] (ORCID: <https://orcid.org/0000-0002-0837-9380>), Rich FitzJohn [ctb], Christian Stigen Larsen [ctb], The LevelDB Authors [cph] |
| Maintainer: | Reed Cartwright <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.2.9000 |
| Built: | 2026-06-06 04:55:19 UTC |
| Source: | https://github.com/reedacartwright/rbedrock |
The nbt data of a actor is saved in the database, using a key with a prefix and a 16-character storage key: 'actor:0123456789abcdef'.
get_actor_value(id, db = default_db()) get_actor_data(ids, db = default_db()) put_actor_value(value, dimension, db = default_db()) put_actor_data(values, dimension, db = default_db()) make_actor_keys(ids) get_actor_keys(db = default_db())get_actor_value(id, db = default_db()) get_actor_data(ids, db = default_db()) put_actor_value(value, dimension, db = default_db()) put_actor_data(values, dimension, db = default_db()) make_actor_keys(ids) get_actor_keys(db = default_db())
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.
get_acdig_value(x, z, dimension, db = default_db()) get_acdig_data(x, z, dimension, db = default_db()) put_acdig_value(value, x, z, dimension, db = default_db()) put_acdig_data(values, x, z, dimension, db = default_db()) read_acdig_value(rawvalue) write_acdig_value(value) create_acdig_keys(x, z, dimension) get_acdig_keys(db = default_db())get_acdig_value(x, z, dimension, db = default_db()) get_acdig_data(x, z, dimension, db = default_db()) put_acdig_value(value, x, z, dimension, db = default_db()) put_acdig_data(values, x, z, dimension, db = default_db()) read_acdig_value(rawvalue) write_acdig_value(value) create_acdig_keys(x, z, dimension) get_acdig_keys(db = default_db())
x, z, dimension
|
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
A character vector. |
values |
A list of character vectors.
If |
rawvalue |
A raw vector. |
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_values() returns a vector of actor keys.
get_acdig_data() returns a named list of the of the values
returned by get_acdig_value().
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).
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)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)
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 |
# 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)# 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)
Minecraft uses several different kind of seeds during world generation and gameplay.
bedrock_random_create_seed(x, z, a, b, salt, type)bedrock_random_create_seed(x, z, a, b, salt, type)
x, z
|
chunk coordinates |
a, b
|
seed parameters |
salt |
seed parameter |
type |
which seed type to use |
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.
# 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 })# 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 })
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.
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, default = getOption("rbedrock.set_default_db") ) ## S3 method for class 'bedrockdb' close(con, compact = FALSE, ...) is_bedrockdb(x)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, default = getOption("rbedrock.set_default_db") ) ## S3 method for class 'bedrockdb' close(con, compact = FALSE, ...) is_bedrockdb(x)
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 |
default |
A logical specifying whether the opened db should be saved
as the default db. If |
con |
An database object created by bedrockdb. |
compact |
Compact database before closing. |
... |
arguments passed to or from other methods. |
x |
An object. |
On success, bedrockdb returns an R6 class of type 'bedrockdb'.
# 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)# 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)
Information about biomes used in Bedrock edition. Generated from the PyMCTranslate project. Colors are generated from the cubiomes project.
biome_dfbiome_df
A data.frame with 87 rows and 5 columns.
The numeric id of the biome.
The name of the biome.
The name of the equivalent biome in Java edition.
The universal name used for the biome in Amulet.
The color used when mapping biomes.
Biomes data is stored as the second map in the Data3D data (tag 43).
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)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)
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 |
get_biomes_value() and get_biomes_data() load Biomes data from db.
get_biomes_value() loads data for a single chunk, and get_biomes_data()
loads data for multiple chunks.
put_biomes_value() and put_biomes_data() store biomes data into db.
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.
LegacyBiomes
BlockEntity data (tag 49) holds a list of NBT values for entity data associated with specific blocks.
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())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())
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. |
get_block_entity_value() and get_block_entity_data() load BlockEntity
data from db. get_block_entity_value() loads data for a single chunk,
and get_block_entity_data() loads data for multiple chunks.
put_block_entity_value() and put_block_entity_data() store BlockEntity
data for one or multiple chunks into db.
get_block_entity_value() returns a list of NBT objects.
get_block_entity_data() returns a named list of lists of NBT objects.
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.
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())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())
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 |
get_blocks_value() and get_blocks_data() load Blocks
data from db. get_blocks_value() loads data for a single chunk,
and get_blocks_data() loads data for multiple chunks.
put_blocks_value() and put_blocks_data() store Blocks
data into db.
get_blocks_value() returns a Blocks value. get_blocks_data()
returns a named list of Blocks values.
SubChunkBlocks
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.
blocks_str(x, names_only = FALSE) blocks_nbt(x)blocks_str(x, names_only = FALSE) blocks_nbt(x)
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. |
Convenience wrappers around [ to extract or replace blocks from an array
based on block coordinates.
chunk_blocks(x, ..., drop = TRUE, origin = chunk_origin(x)) chunk_blocks(x, ..., origin = chunk_origin(x)) <- valuechunk_blocks(x, ..., drop = TRUE, origin = chunk_origin(x)) chunk_blocks(x, ..., origin = chunk_origin(x)) <- value
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 |
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.
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)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)
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 |
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)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
chunk_origin(x) chunk_origin(x) <- valuechunk_origin(x) chunk_origin(x) <- value
x |
an array of block data |
value |
an integer vector |
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'.
get_chunk_actors_value(x, z, dimension, db = default_db()) get_chunk_actors_data(x, z, dimension, db = default_db()) put_chunk_actors_data(values, x, z, dimension, db = default_db()) put_chunk_actors_value(value, x, z, dimension, db = default_db())get_chunk_actors_value(x, z, dimension, db = default_db()) get_chunk_actors_data(x, z, dimension, db = default_db()) put_chunk_actors_data(values, x, z, dimension, db = default_db()) put_chunk_actors_value(value, x, z, dimension, db = default_db())
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 |
ids |
A vector of UniqueIDs. |
get_chunk_actors_value() loads Actors data for a single chunk in db.
get_chunk_actors_data() loads Actors data from multiple chunks in db.
put_chunk_actors_value() and put_chunk_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.
make_actor_keys() creates actor keys based on UniqueIDs.
ChunkVersion data (tag 44) stores the chunk version number for a chunk.
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())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())
x, z, dimension
|
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
An integer |
values |
A (named) vector of ChunkVersion values. If |
get_chunk_version_value() and get_chunk_version_data() load
ChunkVersion data from db. get_chunk_version_value()
loads data for a single chunk, and get_chunk_version_data() loads
data for multiple chunks.
put_chunk_version_value() and put_chunk_version_data()
store ChunkVersion data into db.
get_chunk_version_value() returns a ChunkVersion data
value. get_chunk_version_data() returns a named vector of
ChunkVersion data values.
ChunkVersion
Data3D data (tag 43) stores information about surface heights and biomes in a chunk.
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)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)
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. |
get_data3d_value() and get_data3d_data() load Data3D
data from db. get_data3d_value() loads data for a single chunk,
and get_data3d_data() loads data for multiple chunks.
put_data3d_value() and put_data3d_data() store Data3D
data into db.
write_data3d_value() encodes Data3D data into a raw vector.
read_data3d_value() decodes binary Data3D data.
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.
Data2D
The default db is the db connection that rbedrock uses by default. It defaults to the first opened db, but can also be set by the user.
default_db(db, check = TRUE) with_db(db, code, close = is.character(db)) local_db(db, .local_envir = parent.frame(), close = is.character(db))default_db(db, check = TRUE) with_db(db, code, close = is.character(db)) local_db(db, .local_envir = parent.frame(), close = is.character(db))
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. |
Invoking default_db() returns the current default connection. 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. Closing db
will unset it as the default db as well.
with_db() and local_db() temporarily change the default db.
For default_db(), the calculated value of the default db. For
default_db(db), the previous 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.
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)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.
delete_values( keys, db = default_db(), report = FALSE, readoptions = NULL, writeoptions = NULL )delete_values( keys, db = default_db(), report = FALSE, readoptions = NULL, writeoptions = NULL )
keys |
A character vector of keys. |
db |
A |
report |
A logical indicating whether to generate a report on deleted keys |
readoptions |
A |
writeoptions |
A |
If report == TRUE, a logical vector indicating which keys were
deleted.
FinalizedState data (tag 54) holds a number which indicates a chunk's state of generation.
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())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())
x, z, dimension
|
Chunk coordinates to extract data from.
|
db |
A bedrockdb object. |
value |
An integer |
values |
A (named) vector of FinalizedState values. If |
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() and get_finalized_state_data()
load FinalizedState data from db. get_finalized_state_value()
loads data for a single chunk, and get_finalized_state_data() loads
data for multiple chunks.
put_finalized_state_value() and put_finalized_state_data()
store FinalizedState data into db.
get_finalized_state_value() returns a FinalizedState data
value. get_finalized_state_data() returns a named vector of
FinalizedState data values.
Generate random UUIDs
generate_uuid(n = 1L)generate_uuid(n = 1L)
n |
Number of ids to generate |
A character vector containing random (version 4) UUIDs.
Get a list of keys stored in a bedrockdb.
get_keys(prefix = NULL, db = default_db(), readoptions = NULL)get_keys(prefix = NULL, db = default_db(), readoptions = NULL)
prefix |
A string specifying chunk prefix or string prefix. |
db |
A |
readoptions |
A |
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.
The Named Binary Tag (NBT) format is used by Minecraft for various data types.
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"))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"))
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 |
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.
key_prefix(prefix) begins_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)key_prefix(prefix) begins_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)
prefix |
A string specifying key prefix |
keys |
A character vector of keys |
db |
A |
readoptions |
A |
key |
A single key |
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
locate_blocks(blocks, pattern, negate = FALSE)locate_blocks(blocks, pattern, negate = FALSE)
blocks |
A character array containing block data. |
pattern |
The pattern to look for. Passed to base::grep. |
negate |
If |
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)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)
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.
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())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())
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 |
## Not run: create_world(LevelName = "My World", RandomSeed = 10) ## End(Not run)## Not run: create_world(LevelName = "My World", RandomSeed = 10) ## End(Not run)
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. The "build" functions are useful for automatically converting basic R objects into the most commonly used NBT objects.
nbt_build(x) nbt_build_compound(...)nbt_build(x) nbt_build_compound(...)
x |
an R object |
... |
R objects, possibly named. |
The following conversion rules are used:
nbt_byte: logical or raw scalars
nbt_short: complex scalars (via Im(x))
nbt_int: integer scalars
nbt_long: scalars of class integer64
nbt_float: double scalars
nbt_string: character scalars
nbt_byte_list: logical vectors
nbt_raw_string: raw vectors
nbt_short_list: complex vectors (via Im(x))
nbt_int_list: integer vectors
nbt_long_list: vectors of class integer64
nbt_float_list: double vectors
nbt_string_list: character vectors
nbt_empty_list: NULL
nbt_compound: named lists
nbt_compound_list: unnamed lists
In addition, I() can be used to treat scalars as vectors of length 1, and
to convert unnamed lists to nbt_compounds.
An NBT object with type inferred from x. nbt_build_compound()
always returns an nbt_compound constructed from ....
LL <- bit64::as.integer64(1L) nbt_build_compound( byte = TRUE, short = 1i, int = 1L, long = 1 * LL, float = 1.0, string = "1" )LL <- bit64::as.integer64(1L) nbt_build_compound( byte = TRUE, short = 1i, int = 1L, long = 1 * LL, float = 1.0, string = "1" )
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.
nbt_compound2(...) unnbt(x) nbt_compound(...) nbt_compound0(x) 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(...) nbt_compound_list0(x) nbt_nested_list(x)nbt_compound2(...) unnbt(x) nbt_compound(...) nbt_compound0(x) 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(...) nbt_compound_list0(x) nbt_nested_list(x)
... |
NBT objects, possibly named. |
x |
An nbt payload. |
nbt_*() family of functions create nbt data types.
unnbt() recursively strips NBT metadata from an NBT value.
Create a list of nbt objects.
nbt_list_of(...)nbt_list_of(...)
... |
NBT objects, possibly named. |
PendingTicks data (tag 51) holds a list of NBT values for pending ticks.
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())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())
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. |
get_pending_ticks_value() and get_pending_ticks_data() load
PendingTicks data from db. get_pending_ticks_value() loads data for a
single chunk, and get_pending_ticks_data() loads data for multiple chunks.
put_pending_ticks_value() and put_pending_ticks_data() store
PendingTicks data for one or multiple chunks into db.
get_pending_ticks_value() returns a list of NBT objects.
get_pending_ticks_data() returns a named list of lists of NBT objects.
Write values to a bedrockdb.
put_data(values, keys, db = default_db(), writeoptions = NULL) put_value(value, key, db = default_db(), writeoptions = NULL)put_data(values, keys, db = default_db(), writeoptions = NULL) put_value(value, key, db = default_db(), writeoptions = NULL)
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. |
An invisible copy of db.
RandomTicks data (tag 59) holds a list of NBT values for random ticks.
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())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())
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. |
get_random_ticks_value() and get_random_ticks_data() load RandomTicks
data from db. get_random_ticks_value() loads data for a single chunk,
and get_random_ticks_data() loads data for multiple chunks.
put_random_ticks_value() and put_random_ticks_data() store RandomTicks
data for one or multiple chunks into db.
get_random_ticks_value() returns a list of NBT objects.
get_random_ticks_data() returns a named list of lists of NBT objects.
rbedrock comes bundled with a number of sample files in its inst/extdata
directory. This function make them easy to access.
rbedrock_example(path = NULL) rbedrock_example_world(path)rbedrock_example(path = NULL) rbedrock_example_world(path)
path |
Name of file or directory. If |
rbedrock_example() rbedrock_example("example1.mcworld") rbedrock_example_world("example1.mcworld")rbedrock_example() rbedrock_example("example1.mcworld") rbedrock_example_world("example1.mcworld")
Read and write data from a world's level.dat file.
read_leveldat(path) write_leveldat(object, path, version = 8L)read_leveldat(path) write_leveldat(object, path, version = 8L)
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. |
read_leveldat returns nbt data.
write_leveldat returns a copy of the data written.
# 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)# 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)
Calculate a player-based simulation area
simulation_area(sim_distance, x = 0, z = 0)simulation_area(sim_distance, x = 0, z = 0)
sim_distance |
A sim distance setting |
x, z
|
Chunk coordinates where a player is standing |
A data.frame containing the chunk coordinates in the simulation
area.
Calculate a player-based spawning area
spawning_area(sim_distance, x = 0, z = 0)spawning_area(sim_distance, x = 0, z = 0)
sim_distance |
A sim distance setting |
x, z
|
Chunk coordinates where a player is standing (can be fractional) |
A data.frame containing the chunk coordinates in the spawning area.
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.
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)))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)))
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. |
The format description can be found at https://gist.github.com/Tomcc/a96af509e275b1af483b25c543cfbf37.
get_subchunk_blocks_value() and get_subchunk_blocks_data() load
SubChunkBlocks data from db. get_subchunk_blocks_value() loads data
for a single subchunk, and get_subchunk_blocks_data() loads data for
multiple subchunks.
put_subchunk_blocks_value() and put_subchunk_blocks_data() store
SubChunkBlocks data into db.
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.
get_subchunk_blocks_value() returns a SubChunkBlocks data value.
get_biomes_data() returns a named list of SubChunkBlocks data values.
Information about blocks used in Bedrock edition. Generated from the PyMCTranslate project.
vanilla_block_states_df vanilla_block_list vanilla_block_property_type_listvanilla_block_states_df vanilla_block_list vanilla_block_property_type_list
A data.frame in long-format with 1218 rows and 5 columns. Block data version is 18168865.
Block name.
Property name.
Property type.
Default value.
Allowed values.
List of blocks names. Includes blocks without properties, which don't show up in vanilla_block_states_df.
List of properties (names) and their types (values).