Created
June 28, 2020 00:29
-
-
Save reedacartwright/07d4a6f44f4a0e4ed15e0ff1336707ff to your computer and use it in GitHub Desktop.
A bash script using xdotool to pregenerate a Minecraft Bedrock world using Linux.
This file contains 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
# I use this script to generate a Minecraft world. | |
# I run a BDS instance with sim distance 12 and a | |
# instance of the unofficial Linux client. | |
# Using a server-client setup seems to be more stable | |
# than running client only. | |
# | |
# Make sure your player is in creative and flying before | |
# you begin. | |
# Script parameters | |
sim=12 # sim distance | |
player=RufusAtticus # player's name | |
grid=10 # how big of an area do you want to search | |
sleep_sec=4 | |
# Search variables | |
step=$(((2*sim+1)*16)) | |
low=$((-step*grid)) | |
high=$((step*grid)) | |
# Find windows and pid of your minecraft instance | |
WID=$(xdotool search --name "Minecraft" | tail -n 1) | |
PID=$(xdotool getwindowpid $WID) | |
# function for teletporting player | |
function tp { | |
str="tp $player $1 140 $2 | |
" | |
echo $str | |
xdotool key --clearmodifiers --delay 500 --window $WID Linefeed slash \ | |
type --delay 100 --window $WID --clearmodifiers "$str" | |
sleep $sleep_sec | |
} | |
# Focus the window and exit out of the "pause" screne | |
xdotool windowactivate --sync $WID | |
xdotool key --window $WID Escape | |
sleep $sleep_sec | |
# teleport around the first grid | |
for x in $(seq $low $step $high); do | |
for z in $(seq $low $step $high); do | |
ps -p $PID > /dev/null || exit 1 | |
tp $x $z | |
done | |
done | |
# teleport around the second grid | |
low=$((low-sim*16)) | |
high=$((high+(sim+1)*16)) | |
for x in $(seq $low $step $high); do | |
for z in $(seq $low $step $high); do | |
ps -p $PID > /dev/null || exit 1 | |
tp $x $z | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment