resources/region_files: add a zlib compressed chunk

BodgeMaster 2024-03-24 18:55:52 +01:00
parent b5bb2f45c1
commit e0cb220d37
2 changed files with 18 additions and 2 deletions

Binary file not shown.

View File

@ -5,9 +5,18 @@ else
VERBOSE=false VERBOSE=false
fi fi
if [ "$1" = "-n" ]; then
DECOMPRESS=false
shift
else
DECOMPRESS=true
fi
if [ ! -f "$1" ]; then if [ ! -f "$1" ]; then
echo "Usage: $0 [-v] FILE" echo "Usage: $0 [-v] [-n] FILE"
echo " -v display raw content and NBT dump" echo " -v display raw content and NBT dump"
echo " -n don't decompress"
exit 1 exit 1
fi fi
@ -62,13 +71,20 @@ sys.stdout.buffer.flush()
esac esac
echo " format: $FORMAT ($FORMAT_HEX)" echo " format: $FORMAT ($FORMAT_HEX)"
if $DECOMPRESS; then
dd if="$1" bs=4096 count=$LENGTH skip=$OFFSET 2>/dev/null | dd bs=1 skip=5 count=$(($COMPRESSED_LENGTH-1)) 2>/dev/null | UNCOMPRESS > /tmp/chunk_uncompressed_nbt
else
dd if="$1" bs=4096 count=$LENGTH skip=$OFFSET 2>/dev/null | dd bs=1 skip=5 count=$(($COMPRESSED_LENGTH-1)) 2>/dev/null > /tmp/chunk_compressed_nbt
fi
if $VERBOSE; then if $VERBOSE; then
echo "Raw chunk data:" echo "Raw chunk data:"
echo "$DATA" echo "$DATA"
echo "NBT dump:" echo "NBT dump:"
#TODO: use pipes instead of a file #TODO: use pipes instead of a file
dd if="$1" bs=4096 count=$LENGTH skip=$OFFSET 2>/dev/null | dd bs=1 skip=5 count=$(($COMPRESSED_LENGTH-1)) 2>/dev/null | UNCOMPRESS > /tmp/chunk_uncompressed_nbt #TODO: fix this up to work with both compressed and uncompressed NBT
dumpnbt /tmp/chunk_uncompressed_nbt dumpnbt /tmp/chunk_uncompressed_nbt
rm /tmp/chunk_uncompressed_nbt rm /tmp/chunk_uncompressed_nbt
fi fi