diff --git a/resources/region_files/chunk_compressed_nbt b/resources/region_files/chunk_compressed_nbt new file mode 100644 index 0000000..b1b8ba8 Binary files /dev/null and b/resources/region_files/chunk_compressed_nbt differ diff --git a/resources/region_files/first_chunk.sh b/resources/region_files/first_chunk.sh index 7b04a9f..b61d989 100644 --- a/resources/region_files/first_chunk.sh +++ b/resources/region_files/first_chunk.sh @@ -5,9 +5,18 @@ else VERBOSE=false fi +if [ "$1" = "-n" ]; then + DECOMPRESS=false + shift +else + DECOMPRESS=true +fi + + if [ ! -f "$1" ]; then - echo "Usage: $0 [-v] FILE" + echo "Usage: $0 [-v] [-n] FILE" echo " -v display raw content and NBT dump" + echo " -n don't decompress" exit 1 fi @@ -62,13 +71,20 @@ sys.stdout.buffer.flush() esac 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 echo "Raw chunk data:" echo "$DATA" echo "NBT dump:" #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 rm /tmp/chunk_uncompressed_nbt fi