From 9d30e8dad16918f8f68c2607787b2a5ee5ece59e Mon Sep 17 00:00:00 2001 From: LNSSPsd <24724395+LNSSPsd@users.noreply.github.com> Date: Sun, 18 Dec 2022 01:37:52 -0800 Subject: [PATCH 1/4] Fix Bug Failing Reading Strings Longer Than 127b (#146) [export > command_block] --- io/special_tasks/export.go | 70 ++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/io/special_tasks/export.go b/io/special_tasks/export.go index f012a7ab9..eee51ae24 100644 --- a/io/special_tasks/export.go +++ b/io/special_tasks/export.go @@ -3,8 +3,11 @@ package special_tasks import ( + "io" "fmt" "time" + "math" + "bytes" "phoenixbuilder/fastbuilder/bdump" "phoenixbuilder/fastbuilder/configuration" "phoenixbuilder/fastbuilder/environment" @@ -45,6 +48,35 @@ type SolidRet struct { var ExportWaiter chan map[string]interface{} +type byteAndNormalReader interface { + io.Reader + io.ByteReader +} + +func readNBTString(reader byteAndNormalReader) (string, error) { + // Code mainly from gophertunnel + var length uint32 + for i:=uint(0);i<35;i+=7 { + b, err:=reader.ReadByte() + if(err!=nil) { + return "", fmt.Errorf("Early EOF") + } + length|=uint32(b&0x7f)<math.MaxInt16 { + return "", fmt.Errorf("Invalid string length") + } + buf:=make([]byte, length) + _, err:=io.ReadAtLeast(reader, buf, int(length)) + if err!=nil { + return "", fmt.Errorf("Early EOF") + } + return string(buf), nil +} + func CreateExportTask(commandLine string, env *environment.PBEnvironment) *task.Task { cmdsender:=env.CommandSender // WIP @@ -197,7 +229,7 @@ func CreateExportTask(commandLine string, env *environment.PBEnvironment) *task. ========= Types for command blocks are checked by their names Whether a command block is conditional is checked through its data value. - THEY ARE NOT INCLUDED IN NBT DATA. + SINCE IT IS NOT INCLUDED IN NBT DATA. normal \x01\x00\x00\x00\x00\x01\x00\x00\x00\bsay test\"\x00\x00\x00\x00\x01\xfa\xcd\x03\x00\x00 @@ -230,24 +262,34 @@ func CreateExportTask(commandLine string, env *environment.PBEnvironment) *task. }else if(block=="chain_command_block"||block=="minecraft:chain_command_block"){ mode=packet.CommandBlockChain } + tagContent:=bytes.NewBuffer(__tag) + tagContent.Next(9) len_tag:=len(__tag) tickdelay:=int32(__tag[len_tag-2])/2 exeft:=__tag[len_tag-1] aut:=__tag[4] trackoutput:=__tag[len_tag-6] - cmdlen:=__tag[9] - cmd:=string(__tag[10:10+cmdlen]) - //cmd:=item["Command"].(string) - cusname_len:=__tag[10+cmdlen+2] - cusname:=string(__tag[10+cmdlen+2+1:10+cmdlen+2+1+cusname_len]) - //cusname:=item["CustomName"].(string) - lo_len:=__tag[10+cmdlen+2+1+cusname_len] - lo:=string(__tag[10+cmdlen+2+1+cusname_len+1:10+cmdlen+2+1+cusname_len+1+lo_len]) - //exeft:=item["ExecuteOnFirstTick"].(uint8) - //tickdelay:=item["TickDelay"].(int32) - //aut:=item["auto"].(uint8) - //trackoutput:=item["TrackOutput"].(uint8) - //lo:=item["LastOutput"].(string) + //cmdlen:=__tag[9] + //cmd:=string(__tag[10:10+cmdlen]) + //fmt.Printf("%s\n",cmd) + cmd, err:=readNBTString(tagContent) + if err!=nil { + panic(err) + } + //fmt.Printf("%s\n",cmd) + tagContent.Next(2) + cusname, err:=readNBTString(tagContent) + //cusname_len:=__tag[10+cmdlen+2] + //cusname:=string(__tag[10+cmdlen+2+1:10+cmdlen+2+1+cusname_len]) + if err!=nil { + panic(err) + } + lo, err:=readNBTString(tagContent) + //lo_len:=__tag[10+cmdlen+2+1+cusname_len] + //lo:=string(__tag[10+cmdlen+2+1+cusname_len+1:10+cmdlen+2+1+cusname_len+1+lo_len]) + if err!=nil { + panic(err) + } conb_bit:=static_item["conditional_bit"].(uint8) conb:=false if conb_bit==1 { From dfb56507e3354dfe01128306d75434bd6a973353 Mon Sep 17 00:00:00 2001 From: LNSSPsd <24724395+LNSSPsd@users.noreply.github.com> Date: Sun, 18 Dec 2022 01:46:21 -0800 Subject: [PATCH 2/4] Bump version: 3.7.0 --- .github/workflows/build.yml | 42 +++++++++++++++++++------------------ version | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05297176c..49ba4186b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,6 +102,8 @@ jobs: # Debian/Ubuntu provided LLVM only support native targets, using Homebrew prebuilt for all targets - name: Setup LLVM dependencies + continue-on-error: true + # ^ Idk why apt would ever return the exit code 8 saying I should reboot run: | sudo apt install libedit2 libxml2 libncursesw6 binutils elfutils wget -q http://ftp.debian.org/debian/pool/main/libf/libffi/libffi8_3.4.2-4_amd64.deb @@ -262,24 +264,24 @@ jobs: # git commit -m "Auto update" -a # git push # cd .. - - - name: Load Key - env: - FBKEY: ${{ secrets.FBKEY }} - if: ${{ env.FBKEY != '' }} - run: | - echo "$FBKEY">~/fbkey - mkdir -p ~/.ssh - printf "StrictHostKeyChecking no\nUserKnownHostsFile /dev/null">~/.ssh/config - chmod 0600 ~/fbkey - - - name: Upload binaries and publish - env: - FBUSER: ${{ secrets.FBUSER }} - FBIP: ${{ secrets.FBIP }} - if: ${{ env.FBUSER != '' && env.FBIP != '' }} - run: | - echo "put fb-upload.tar.gz">~/a - sftp -P 8964 -i ~/fbkey -b ~/a $FBUSER@$FBIP - ssh -i ~/fbkey $FBUSER@$FBIP -p 8964 "mkdir -p fbbinaries;mv fb-upload.tar.gz fbbinaries/;cd fbbinaries;tar -xzf *.tar.gz;rm *.tar.gz;mv build/* ./;rmdir build;rm -rf /var/www/storage/*;mv * /var/www/storage/;cd ..;rmdir fbbinaries" + # + #- name: Load Key + # env: + # FBKEY: ${{ secrets.FBKEY }} + # if: ${{ env.FBKEY != '' }} + # run: | + # echo "$FBKEY">~/fbkey + # mkdir -p ~/.ssh + # printf "StrictHostKeyChecking no\nUserKnownHostsFile /dev/null">~/.ssh/config + # chmod 0600 ~/fbkey + # + #- name: Upload binaries and publish + # env: + # FBUSER: ${{ secrets.FBUSER }} + # FBIP: ${{ secrets.FBIP }} + # if: ${{ env.FBUSER != '' && env.FBIP != '' }} + # run: | + # echo "put fb-upload.tar.gz">~/a + # sftp -P 8964 -i ~/fbkey -b ~/a $FBUSER@$FBIP + # ssh -i ~/fbkey $FBUSER@$FBIP -p 8964 "mkdir -p fbbinaries;mv fb-upload.tar.gz fbbinaries/;cd fbbinaries;tar -xzf *.tar.gz;rm *.tar.gz;mv build/* ./;rmdir build;rm -rf /var/www/storage/*;mv * /var/www/storage/;cd ..;rmdir fbbinaries" diff --git a/version b/version index b72762837..7c69a55db 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.6.2 +3.7.0 From d87c5ce0c4c79aee8a2ee814a6e82fd973169979 Mon Sep 17 00:00:00 2001 From: LNSSPsd <24724395+LNSSPsd@users.noreply.github.com> Date: Sun, 18 Dec 2022 02:02:58 -0800 Subject: [PATCH 3/4] Use newer libffi8 so that it will not be 404 --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49ba4186b..b500c9028 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -102,11 +102,9 @@ jobs: # Debian/Ubuntu provided LLVM only support native targets, using Homebrew prebuilt for all targets - name: Setup LLVM dependencies - continue-on-error: true - # ^ Idk why apt would ever return the exit code 8 saying I should reboot run: | sudo apt install libedit2 libxml2 libncursesw6 binutils elfutils - wget -q http://ftp.debian.org/debian/pool/main/libf/libffi/libffi8_3.4.2-4_amd64.deb + wget -q http://ftp.debian.org/debian/pool/main/libf/libffi/libffi8_3.4.4-1_amd64.deb sudo dpkg -i libffi8_3.4.2-4_amd64.deb - name: Cache LLVM From 9340bb752967ebb4a50a70d04051af04c7ef9685 Mon Sep 17 00:00:00 2001 From: LNSSPsd <24724395+LNSSPsd@users.noreply.github.com> Date: Sun, 18 Dec 2022 03:07:55 -0800 Subject: [PATCH 4/4] Correct libffi8 version --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b500c9028..8d97ad7a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,7 +105,7 @@ jobs: run: | sudo apt install libedit2 libxml2 libncursesw6 binutils elfutils wget -q http://ftp.debian.org/debian/pool/main/libf/libffi/libffi8_3.4.4-1_amd64.deb - sudo dpkg -i libffi8_3.4.2-4_amd64.deb + sudo dpkg -i libffi8_3.4.4-1_amd64.deb - name: Cache LLVM id: cache-llvm