Skip to content

Instantly share code, notes, and snippets.

@reedacartwright
Created March 14, 2020 00:26
Show Gist options
  • Save reedacartwright/35c2fea70d63348426148e2a4fa09918 to your computer and use it in GitHub Desktop.
Save reedacartwright/35c2fea70d63348426148e2a4fa09918 to your computer and use it in GitHub Desktop.
A script for identifying all spawners in a Minecraft World
# uncomment and reinstall rbedrock to get the latest code.
# devtools::install_github("reedacartwright/rbedrock", INSTALL_opts="--no-multiarch")
library(tidyverse)
library(rbedrock)
# Local copy of the Advanced Automation Realm
# replace with your own world id
dbpath <- "XBdsXqo+AAA="
# Open the Database
db <- bedrockdb(dbpath)
# Read all keys
keys <- db$keys() %>% parse_chunk_keys()
# Find Overworld BlockEntity keys
block_entity_keys <- keys %>% filter(tag == "BlockEntities" & dimension == 0) %>% pull(key)
# Extract NBT data from the database
nbt_data <- db$mget(block_entity_keys) %>% map(read_nbt)
# close the db
db$close()
# identify spawners
dat <- nbt_data %>% flatten() %>% keep(~.$id == "MobSpawner") %>% bind_rows()
# check if you have any old-style spawners and fixup as needed
if(any(is.na(dat$EntityIdentifier))) {
dat <- dat %>% mutate(EntityIdentifier = if_else(!is.na(EntityIdentifier),
EntityIdentifier, recode(EntityId,
"32" = "minecraft:zombie",
"34" = "minecraft:skeleton",
"35" = "minecraft:spider",
"39" = "minecraft:silverfish",
"40" = "minecraft:cave_spider",
"43" = "minecraft:blaze",
"199456" = "minecraft:zombie",
"1116962" = "minecraft:skeleton",
"264995" = "minecraft:spider",
"264999" = "minecraft:silverfish",
"265000" = "minecraft:cave_spider",
"2859" = "minecraft:blaze",
"33753888" = "minecraft:zombie",
"34671394" = "minecraft:skeleton",
"33819427" = "minecraft:spider",
"33819431" = "minecraft:silverfish",
"33819432" = "minecraft:cave_spider",
"33557291" = "minecraft:blaze",
.default = ""
)))
}
# extract spawner info
spawners <- dat %>% transmute(x,y,z,Entity = str_replace(EntityIdentifier, "minecraft:",""))
# save data (by default in Documents directory)
write_csv(spawners, "spawners_overworld.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment