-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.sh
138 lines (112 loc) · 3.12 KB
/
autogen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#set -x
# This works by teleporting a player around the map in an expanding spiral.
# Bonus: if the player client has a mapmod like Journey Maps, it will map the world as it runs
# How to use:
# 0. Put this script in your minecraft server root with LaunchServer.sh
# 1. From the minecraft server root directory, run your server inside a 'screen' session with the following command
# screen -dmSL minecraft sh LaunchServer.sh
# 2. Log your player in (creative mode w/ hover on)
# 3. Set the 'user' line below to your player name
# 4. To start exploring run
# ./autogen.sh
# 5. Press CTRL-C to stop (assuming you don't reach max_distance)
# 6. If you want to resume, from the previously quit *jump number* run:
# ./autogen.sh [jumpnumber]
# Note: It teleports to the max height first and then "climbs" in y-jumps to try to trigger some of the ruins proximity command blocks
user="Gun_Arm";
startx=0;
startz=0;
jump=110;
max_distance=10000; # block distance to bail
miny=60;
jumpy=17;
maxy=260;
if [ -z "$1" ]; then skip=0; else skip=$1; fi
function cool_cpu
{
threshold=25
current=$(mpstat 1 1 | awk '$12 ~ /[0-9.]+/ { print int(100 - $12 + 0.5) }')
while [[ "$current" -ge "$threshold" ]]; do
echo "CPU% $current >= $threshold"
current=$(mpstat 1 1 | awk '$12 ~ /[0-9.]+/ { print int(100 - $12 + 0.5) }')
done
}
function check_session
{
if ! screen -list | grep -q "minecraft"; then
echo "Server screen-session is not active"
quit;
fi
}
function teleport
{
check_session;
screen -S minecraft -p 0 -L -X stuff "/tp $user $1 $2 $3
"
}
function use_location
{
MCX=$1;
MCZ=$2;
teleport $MCX $maxy $MCZ;
cool_cpu;
if [[ 1 -eq 1 ]]; then
for (( height=$miny; $height < $maxy; height=$(($height + $jumpy)) ))
{
echo "y->$height"
teleport $MCX $height $MCZ;
sleep .5;
}
cool_cpu;
fi
sleep 1;
}
function quit
{
exit 1;
}
function react_to_output
{
if [ ! -f "screenlog.0" ]; then return; fi
mv screenlog.0 screenlog.tmp
if grep -q "That player cannot be found" "screenlog.tmp"; then
echo "$user is not connected."
quit;
fi
rm screenlog.tmp
}
function spiral
{
rm screenlog.*
x=0;
y=0;
dx=0;
dy=-1;
t=$(($max_distance / $jump))
total_jumps=$(($t * $t));
#cool_cpu;
#teleport $startx $maxy $startz
cool_cpu;
for (( i=1; $i < $total_jumps + 1; i=$(($i + 1)) ))
{
react_to_output;
MCX=$(($startx + $jump * $x));
MCZ=$(($startz + $jump * $y));
if [[ $i -ge $skip ]]; then
echo "$i out of $total_jumps : MC x,y : $MCX, $MCZ";
use_location $MCX $MCZ;
else
echo "skipping jump $i";
fi
if [[ ( $x -eq $y ) || ( ( $x -lt 0 ) && ( $x -eq $((-1 * $y)) ) ) || ( ( $x -gt 0 ) && ( $x -eq $((1 - $y)) ) ) ]]; then
t=$dx;
dx=$((-1 * $dy));
dy=$t;
fi
x=$(($x + $dx));
y=$(($y + $dy));
}
echo "Exploration Completed!";
}
spiral