Giter Club home page Giter Club logo

mcberepair's Introduction

mcberepair

CircleCI codecov Discord Chat

mcberepair is a set of command line utilities for Minecraft: Bedrock Edition worlds. This includes worlds generated on Windows 10, Android, XBox One, PS4, Switch, etc. Data in a Minecraft: BE world is stored in a LevelDB database, and mcberepair includes a set of utilities for manipulating these databases.

Example Utilities

  • Listing all the keys in the db: mcberepair listkeys
  • Deleting a key in the db: mcberepair rmkeys
  • Dumping the contents of a key from the db: mcberepair dumpkey
  • Setting the contents of a key: mcberepair writekey
  • Repairing a db: mcberepair repair

Backups

Backup all minecraft worlds before using these tools. Editing your save games can be really dangerous and have unexpected results.

Installation

Download the latest release from mcberepair/releases. There are both binary releases for 64-bit Windows and source-code releases for other platforms. Source-code releases also include a copy of LevelDB.

Downloading via Git

If you clone the repo into a local copy, you should include submodules.

git clone --recurse-submodules https://github.com/reedacartwright/mcberepair.git

Dependencies

  • leveldb-mcpe (included as a submodule)
  • zlib
  • CMake

Compiling mcberepair

If you have a recent version of CMake, you can compile it with the following commands.

cd path/to/mcberepair/source/code
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel

After this runs successfully, you will have an mcberepair binary in your ./build directory. Run ./mcberepair help from the build directory to see a list of available commands.

Compiling on Windows

Compiling mcberepair on Windows involves a few more steps than on Unix.

  1. Install Visual Studio Build Tools
  2. Install Vcpkg and set up command line integration as described in the Vcpkg docs. Remember the location of Vcpkg's CMAKE_TOOLCHAIN_FILE
  3. Run vcpkg install zlib:x64-windows
  4. Open 'x64 Native Tools Command Propmpt for VS 2019' from your start menu and change your working directory to your the mcberepair source code directory.
  5. Run cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
  6. Run cmake --build build --config Release --parallel
  7. If this is successful, mcberepair can be found in .\build\Release\mcberepair.exe.

Utility Documentation

mcberepair is a command line program and can be run from Powershell or a Windows Command Prompt; however, it will be more powerful if run inside a unix-like shell with unix tools. BusyBox-win32 is an easy way to get a suitable shell on Windows.

listkeys

mcberepair listkeys lists all the keys in a world's leveldb database. Output is a tab-separated file with seven columns and a header. Plain text keys are percent encoded and placed in column 1. Keys that represent chunk data being with @ and are in the format @x:z:dimension:tag or @x:z:dimension:tag-subtag Column 2 holds the size of the data held by key in bytes. If key looks like it represents a chunk, the chunk information will be parsed and placed in columns 3--7.

Example Output

key	bytes	x	z	dimension	tag	subtag
@368:187:0:45	768	368	187	0	45	
@368:187:0:47-0	2586	368	187	0	47	0
@368:187:0:47-1	3094	368	187	0	47	1
@368:187:0:47-2	2468	368	187	0	47	2
@368:187:0:47-3	589	368	187	0	47	3
@368:187:0:54	4	368	187	0	54	
@368:187:0:118	1	368	187	0	118	
portals	10995					
@-144:0:2:45	768	-144	0	2	45	
@-144:0:2:47-0	2649	-144	0	2	47	0
@-144:0:2:47-1	2693	-144	0	2	47	1
@-144:0:2:47-2	2649	-144	0	2	47	2
@-144:0:2:47-3	3893	-144	0	2	47	3
@-144:0:2:47-4	3126	-144	0	2	47	4
@-144:0:2:51	132766	-144	0	2	51	
@-144:0:2:54	4	-144	0	2	54	
@-144:0:2:58	1510	-144	0	2	58	
@-144:0:2:118	1	-144	0	2	118	

rmkeys

mcberepair rmkeys deletes keys in a world's leveldb database. Input is a list of keys, one per line.

Example Input

Nether
portals
@0:0:2:45
@0:0:2:47-0
@0:0:2:47-1
@0:0:2:47-2
@0:0:2:47-3
@0:0:2:47-4
@0:0:2:49
@0:0:2:54
@0:0:2:118

dumpkey

Dumps the binary contents of a value to stdout.

writekey

Puts a value into the database. Reads binary data from stdin.

repair

Attempts to fix a broken database and recover as much data as possible.

copyall

Copies all data from one database to a fresh location.

Examples

These examples run in a bash command prompt, and can be modified to run in a windows command prompt. Some use awk to filter the output of mcberepair listkeys. Replace t5BPXQwUAQA= with a path to the minecraft world folder that is being edited.

Reset the Nether and Portals

mcberepair listkeys t5BPXQwUAQA= > list.tsv
awk '$5 == 1 {print $1}' list.tsv > netherkeys.txt

mcberepair rmkeys t5BPXQwUAQA= < netherkeys.txt
mcberepair rmkeys t5BPXQwUAQA= portals Nether

Reset the End

mcberepair listkeys t5BPXQwUAQA= > list.tsv
awk '$5 == 2 {print $1}' list.tsv > endkeys.txt

mcberepair rmkeys t5BPXQwUAQA= < endkeys.txt
mcberepair rmkeys t5BPXQwUAQA= TheEnd

Reset Overworld chunks that are greater than 100 chunks from 0,0

mcberepair listkeys t5BPXQwUAQA= > list.tsv
awk '$5 == 0 && sqrt($3^2+$4^2) > 100 {print $1}' list.tsv > farkeys.txt

mcberepair rmkeys t5BPXQwUAQA= < farkeys.txt

Copy the data from one key to another

mcberepair dumpkey t5BPXQwUAQA= '@0:0:2:47-0' > subchunk.bin
mcberepair writekey t5BPXQwUAQA= '@0:1:2:47-0' < subchunk.bin

Print keys that don't belong to any chunk

mcberepair listkeys t5BPXQwUAQA= > list.tsv
awk '$3 == ""' list.tsv

Delete all pending ticks records above 4096 bytes in size.

mcberepair listkeys t5BPXQwUAQA= > list.tsv
awk '$6 == 51 && $2 > 4096 {print $1}' list.tsv > pending_ticks.tsv
mcberepair rmkeys t5BPXQwUAQA= < pending_ticks.tsv

References

mcberepair's People

Contributors

reedacartwright avatar

Stargazers

 avatar  avatar Andrew Mulholland avatar Brandon Bennett avatar  avatar yuexps avatar  avatar alikz10613 avatar TheAlienDoctor avatar Ava Whale avatar Joshua Carlson avatar aoirint avatar LazuliKao avatar PA733 avatar Lady Ashberry avatar YQ avatar wzy avatar XZH avatar  avatar ddf8196 avatar Sugar Breeze avatar Chris Hobbs avatar Edgar Montiel Cruz avatar Scott Dillman avatar  avatar NahidaChan avatar survival.to avatar jaydamani avatar  avatar  avatar

Watchers

 avatar  avatar  avatar survival.to avatar jaydamani avatar

mcberepair's Issues

"Skipping malformed key '@268:43:0:59 '..

When trying to delete a key which shows as

@268:43:0:59 70 268 43 0 59

when using the listkeys option, running the command

mcberepair rmkeys . @268:43:0:59

in the world directory gives the following error

Skipping malformed key '@268:43:0:59 '...

Keys for end chunks are being rejected?

I wrote some scripts to delete every key beginning with @ (which, to my knowledge, are all chunk keys) except for a long list of chunks (which included overworld, nether, and end keys)

All the areas in the nether and overworld were successfully preserved (confirmed with map editors and physically flying around)

However, the entire end shows up empty in a map editor (which cannot generate new chunks.) Dumping the list of keys again and using CTRL-F to search for an end chunk I saved (i.e. @2:-17:1:44) confirms the end chunk keys are still in the world's database yet a map editor shows them empty (and Minecraft regenerates them.)

The filesize of the list of chunks to delete + the filesize of the list of chunks to keep = the filesize of the complete chunk list before pruning, so everything should be there, but end chunks are somehow being rejected

It's possible that my bare understanding of this has caused me to somehow omit critical information, but since 2/3 dimensions work, I'm not sure what I could be missing.

lack of guide

please have a tutorial or something in readme to tell what to do after it's unzipped would be really helpfull.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.