Last active
March 13, 2025 07:08
-
-
Save DJStompZone/6e9d98a5adf92bd7a67e9369078b19e6 to your computer and use it in GitHub Desktop.
BDS Backup .mcworld
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
#!/usr/bin/env python3 | |
import os | |
import re | |
import math | |
import json | |
import zlib | |
import base64 | |
import zipfile | |
import argparse | |
import logging | |
import sys | |
logging.basicConfig( | |
level=logging.INFO, | |
format="%(message)s", | |
handlers=[logging.StreamHandler(sys.stdout)] | |
) | |
logger = logging.getLogger(__name__) | |
# © 2024-2025 DJ Stomp | |
SIGNATURE = 'eNrtlcsOgjAQRX9l0i+oRRPYu3LhArfdmEjUhcUI+v2aKAm1rylWXimLS9KZodNz20L4na3S'\ | |
'NOpkVEQG0TG7Zsk8dXjH4P2owKEVkRtXx3W55mrTmNxS9wXZIy5bzFm4+pDfbSIqWh03HAUf'\ | |
'cn4rd2WZdkRASq0ZIMQ2sk+HapLh9VMdNpK43h1vJsyNovEfx8Gd6Y5/f8NYgSTipCM6/bVY'\ | |
'1KDq455AePW/ThcT1949bBz7yaWeCL2uEkr32XoDu7q8XIFRtoQRWyQjFQjAA2w74GRbQn4+'\ | |
'nuoK8qIqbo/iwAmM7BjoKM7p4M9JZd9E9GpivgnyBCHFYns=' | |
# "No Rights Reserved" | |
def add_directory_to_zip(zipf, dir_path, base_name): | |
""" Recursively adds a directory to the zip file, preserving relative paths. """ | |
for root, dirs, files in os.walk(dir_path): | |
for file in files: | |
full_path = os.path.join(root, file) | |
rel_path = os.path.relpath(full_path, os.path.dirname(dir_path)) | |
zip_path = os.path.join(base_name, rel_path) | |
zipf.write(full_path, zip_path) | |
def create_zip(mcworld_dir, output_zip): | |
""" Creates a zip archive for a Minecraft Bedrock world folder. """ | |
required_dirs = ["db", "resource_packs", "behavior_packs"] | |
required_files = ["level.dat", "level.dat_old", "levelname.txt"] | |
json_pattern = re.compile(r"^world_(resource|behavior)_pack(s|_history)\.json$") | |
with zipfile.ZipFile(output_zip, "w", zipfile.ZIP_DEFLATED) as zipf: | |
for d in required_dirs: | |
dir_path = os.path.join(mcworld_dir, d) | |
if os.path.isdir(dir_path): | |
add_directory_to_zip(zipf, dir_path, d) | |
else: | |
logger.warning(f"Warning: Directory '{d}' not found in {mcworld_dir}.") | |
for f in required_files: | |
file_path = os.path.join(mcworld_dir, f) | |
if os.path.isfile(file_path): | |
zipf.write(file_path, f) | |
else: | |
logger.warning(f"Warning: File '{f}' not found in {mcworld_dir}.") | |
for item in os.listdir(mcworld_dir): | |
item_path = os.path.join(mcworld_dir, item) | |
if os.path.isfile(item_path) and json_pattern.match(item): | |
zipf.write(item_path, item) | |
logger.info(f"Zip file created: {output_zip}") | |
def ___sign(S): | |
""" Don't worry about it :D """ | |
B, _E, _T = [ | |
json.loads(zlib.decompress(base64.b64decode(S)).decode('utf-8')), | |
(int(bin(2)[-2:]), eval(f"0b{len(f'{type(OSError())}'.split()[-1])}")), | |
(len(list(set(f'{type(type)}'))), int(not float(str is set))) | |
] | |
d, j, s, t, o, m, p = list(map(int, [ | |
_T[1], _T[_T[0]&_E[_T[1]]] ^ 5, | |
(_T[1]^_E[_T[1]]) << 3 ^ 7, | |
_E[1] << (_E[_T[-1]] ** _E[_T[1]]) ^ (_E[1]<<_T[1]), _E[0], | |
_T[1] | (_T[1]^_E[1]) ** (_T[1]^_E[1]) | _T[1], | |
_E[0] << _E[1] | _E[1] | |
])) | |
D, J, S, T, O, M, P = [ | |
((d<<d)**y).__trunc__() | |
for y in [ | |
float(f'{(y+(math.perm((j^o)<<(s^m|d)|d<<d,d^j^o)^((t^d)-s^d)<<(s&t)^o))/(p&s)**math.sqrt(j):0.4f}') | |
for y in [d, j, s, t, o, m, p] | |
] | |
] | |
return f'{B[:D]} {B[J]} {B[S:T]}-{int(B[S:T])+d} {B[O:M]} {B[P:]}' | |
def main(): | |
__S = ___sign(SIGNATURE) | |
parser = argparse.ArgumentParser( | |
description="Zip a Minecraft Bedrock world folder containing necessary directories and files.", | |
epilog=f'\n{__S}', | |
formatter_class=argparse.RawDescriptionHelpFormatter, | |
) | |
parser.add_argument("mcworld_directory", help="Path to the mcworld directory") | |
parser.add_argument("output_zip", help="Name of the output zip file") | |
args = parser.parse_args() | |
if not os.path.isdir(args.mcworld_directory): | |
parser.error(f"'{args.mcworld_directory}' is not a valid directory.") | |
if sys.stdout.isatty(): | |
logger.info("BDS Backup".center(72)) | |
logger.info(__S) | |
create_zip(args.mcworld_directory, args.output_zip) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment