You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1001 B

import math
import time
from itertools import count
from mcrcon import MCRcon
IP = '127.0.0.1'
PASS = 'jean-qot'
PLAYER = '_Wreckinq_'
STEP = 32
SLEEP = 2
START = 31895
def spiral(n):
k = math.ceil((math.sqrt(n)-1)/2)
t = 2 * k + 1
m = t**2
t = t - 1
if n >= m-t:
return k-(m-n), -k
else:
m = m-t
if n >= m-t:
return -k, -k+(m-n)
else:
m = m-t
if n >= m-t:
return -k+(m-n), k
else:
return k, k-(m-n-t)
def gen_chunks():
with MCRcon(IP, PASS) as mcr:
resp = mcr.command('/gamemode creative {}'.format(PLAYER))
if resp == 'No player was found':
print(resp)
return
for step in count(START):
chunk = spiral(step)
coords = [STEP*x + STEP//2 for x in chunk]
print('Step {}: {}'.format(str(step), str(coords)))
mcr.command('/tp {} {} 150 {}'.format(PLAYER, *coords))
time.sleep(SLEEP)
gen_chunks()