Skip to content

Instantly share code, notes, and snippets.

@seakintruth
Last active April 12, 2020 01:08
Show Gist options
  • Save seakintruth/27c93bf174c2cc25131932be34e32fa3 to your computer and use it in GitHub Desktop.
Save seakintruth/27c93bf174c2cc25131932be34e32fa3 to your computer and use it in GitHub Desktop.
Minecraft java linux script for AFK zombie xp farm --- Depends: xdotool
#!/usr/bin/env bash
echo "afkZombieXpFarm.sh::Run the most recent version with"
echo "bash <(curl https://gist.githubusercontent.com/seakintruth/27c93bf174c2cc25131932be34e32fa3/raw)"
echo "bash <(wget -q -O - https://gist.githubusercontent.com/seakintruth/27c93bf174c2cc25131932be34e32fa3/raw)"
echo "clicking: $1"
echo [ -z "$*" ]
date1=$((`date +%s`));
i=0;
# Building functions per https://tldp.org/LDP/abs/html/complexfunct.html
runClickCycle (){
currentClick=$1
planedClicks=$2
xdotool click 1
echo "Click $currentClick of $planedClicks $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S) $((currentClick % 500))\r";
echo $((currentClick % 100))
if [ $((currentClick % 100)) == 42 ]; then
xdotool click 4;
xdotool mousedown 3;
echo -ne "Right Click with 5 second delay after mouse down $currentClick of $planedClicks $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 5;
xdotool mouseup 3;
fi
sleep 0.02;
echo "$currentClick clicks in $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)";
}
install_if_missing() {
# https://stackoverflow.com/a/22592801/1146659
local package_name=$1
if [ $(dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo -n "Attempt to install package $package_name? [yes or no]: "
read yno
case $yno in
[yY] | [yY][Ee][Ss] )
printf "Missing $package_name. Setting up $package_name. \n"
sudo apt-get --yes install $package_name
;;
[nN] | [nN][oO] )
printf "Package $package_name is required \n"
exit 1;
;;
*)
printf "Invalid Input \n"
exit 1;
;;
esac
fi
}
install_if_missing xdotool
if [ ${1} ]; then
while [ $i -lt $1 ]; do
runClickCycle "$i" "$1"
let i=i+1;
done
else
while [ $i -lt 200000 ]; do
runClickCycle "$i" "$1"
let i=i+1;
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment