diff --git a/demos/map.sh b/demos/map.sh new file mode 100644 index 0000000..9d693f5 --- /dev/null +++ b/demos/map.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +function hook_chunks() { + log "hooking chunks" + echo "ffff081f00 01 09 0a 0e 0f 15 21 00 31 00 41 42 44 45 47 49 4d 9401 8402 8602 8702 8902 00 9602 00 00 00 00 00 f60a8004" > $TEMP/world/0000000000000000 + + map="" + for (( i=0; i<4097; i++ )); do + map+="$(printf '%02x' $((RANDOM%15)))" + done + + echo "$map" >> $TEMP/world/0000000000000000 + + echo "000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001" >> $TEMP/world/0000000000000000 + + pkt_chunk FFFFFFFF FFFFFFFF + pkt_chunk FFFFFFFF 00000000 + pkt_chunk FFFFFFFF 00000001 + + pkt_chunk 00000000 FFFFFFFF + pkt_chunk 00000000 00000000 + pkt_chunk 00000000 00000001 + + pkt_chunk 00000001 FFFFFFFF + pkt_chunk 00000001 00000000 + pkt_chunk 00000001 00000001 +} diff --git a/mc.sh b/mc.sh index 7ccf544..0bdc9dc 100755 --- a/mc.sh +++ b/mc.sh @@ -12,6 +12,11 @@ source src/int.sh source src/packet.sh source src/hooks.sh +if [[ -f "$1" ]]; then + log "Loading plugin: $1" + source "$1" +fi + function keep_alive() { while true; do sleep 5 diff --git a/src/packet.sh b/src/packet.sh index 3a67bed..16a2250 100644 --- a/src/packet.sh +++ b/src/packet.sh @@ -28,33 +28,35 @@ function pkt_chunk() { # nbt tag MOTION_BLOCKING len light data for a superflat map res+="0a00000c000f 4d4f54494f4e5f424c4f434b494e47 00000025 010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804010080402010080401008040201008040100804020100804 0000000020100804 00" - chunk="ffff" # amount of blocks, doesnt matter - chunk+="08" # palette - bits per block - #chunk+="04" # palette - bits per block - chunk+="$(int2varint ${#palette[@]})" # palette - entries amount - #chunk+="04" + if [[ -f $TEMP/world/$1$2 ]]; then + chunk=$(cat $TEMP/world/$1$2) + else + chunk="ffff" # amount of blocks, doesnt matter + chunk+="08" # palette - bits per block + #chunk+="04" # palette - bits per block + chunk+="$(int2varint ${#palette[@]})" # palette - entries amount + #chunk+="04" - chunk+="${palette[@]}" - #chunk+="0f af0b 01 00" + chunk+="${palette[@]}" + #chunk+="0f af0b 01 00" - chunk+="8004" # len of next array - l=$(echo -n "8002" | xxd -p -r | varint2int) + chunk+="8004" # len of next array + l=$(echo -n "8002" | xxd -p -r | varint2int) - for (( i=0; i<$((l*16)); i++ )); do - chunk+="01" # third entry of palette - done + for (( i=0; i<$((l*16)); i++ )); do + chunk+="01" # third entry of palette + done - chunk+="0001" # biome palette - for i in {1..26}; do - chunk+="0000000000000001" # set biome - done + chunk+="0001" # biome palette + for i in {1..26}; do + chunk+="0000000000000001" # set biome + done + echo -n "$chunk" > $TEMP/world/$1$2 + fi - warn $(hexstr_len "$chunk") res+="$(hexstr_len "$chunk")" # Data len res+="$chunk" # Chunk data itself - rhexlog "$res" - res+="00 01 00 00 00 00 00 00" # empty bitsets and light arrays echo -n "$(hexpacket_len "$res")22$res" | xxd -p -r