Created
August 27, 2020 07:15
-
-
Save reedacartwright/38b8828fcb16ba4c6eed32904916cfcf to your computer and use it in GitHub Desktop.
Use rbedrock to create a normal, void world. User can specify overworld, nether, and end biomes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a normal void world with specified biomes in | |
# the overworld, nether, and end dimensions. | |
# | |
# This script takes an input an existing world. It will | |
# delete all data in the world and replace it with void | |
# terrain. | |
# script controls | |
biomes <- c("plains", "hell", "the_end") | |
dbpath <- A_PATH_TO_A_WORLD_HERE | |
########################################################### | |
# load libraries | |
library(tidyverse) | |
library(glue) | |
library(rbedrock) | |
# load database | |
db <- bedrockdb(dbpath) | |
# chunk data | |
chunk_version <- as.raw(0xf) | |
finalization <- as.raw(c(0x2,0x0,0x0,0x0)) | |
# height map data | |
height_map <- rep(as.raw(c(0x0,0x0)),256L) | |
# create biome data | |
biomes <- as.raw(biome_id(biomes)) | |
overworld_biome <- rep(biomes[1],256L) | |
nether_biome <- rep(biomes[2],256L) | |
end_biome <- rep(biomes[3],256L) | |
overworld_maps <- c(height_map, overworld_biome) | |
nether_maps <- c(height_map, nether_biome) | |
end_maps <- c(height_map, end_biome) | |
# create chunk positions | |
g <- expand_grid(x=-64:63,z=-64:63) | |
# DANGER: erase database | |
db$delete(db$keys()) | |
#### Overworld #### | |
# 2dmaps | |
k <- g %>% glue_data("@{x}:{z}:0:45") | |
dat <- rep(list(overworld_maps),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# finalization | |
k <- g %>% glue_data("@{x}:{z}:0:54") | |
dat <- rep(list(finalization),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# version | |
k <- g %>% glue_data("@{x}:{z}:0:118") | |
dat <- rep(list(chunk_version),length(k)) %>% set_names(k) | |
db$mput(dat) | |
#### Nether #### | |
# 2dmaps | |
k <- g %>% glue_data("@{x}:{z}:1:45") | |
dat <- rep(list(nether_maps),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# finalization | |
k <- g %>% glue_data("@{x}:{z}:1:54") | |
dat <- rep(list(finalization),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# version | |
k <- g %>% glue_data("@{x}:{z}:1:118") | |
dat <- rep(list(chunk_version),length(k)) %>% set_names(k) | |
db$mput(dat) | |
#### End #### | |
# 2dmaps | |
k <- g %>% glue_data("@{x}:{z}:2:45") | |
dat <- rep(list(end_maps),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# finalization | |
k <- g %>% glue_data("@{x}:{z}:2:54") | |
dat <- rep(list(finalization),length(k)) %>% set_names(k) | |
db$mput(dat) | |
# version | |
k <- g %>% glue_data("@{x}:{z}:2:118") | |
dat <- rep(list(chunk_version),length(k)) %>% set_names(k) | |
db$mput(dat) | |
db$close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment