From c67ce889a13b3857409e27f467a0648e66765c27 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 4 Jul 2019 21:30:17 +0000 Subject: [PATCH] Initial commit --- minecraftondemand/minecraftondemand.py | 25 +++++++++++++ minecraftondemand/requirements.txt | 2 ++ pychunkgen/pychunkgen.py | 50 ++++++++++++++++++++++++++ pychunkgen/requirements.txt | 2 ++ 4 files changed, 79 insertions(+) create mode 100644 minecraftondemand/minecraftondemand.py create mode 100644 minecraftondemand/requirements.txt create mode 100644 pychunkgen/pychunkgen.py create mode 100644 pychunkgen/requirements.txt diff --git a/minecraftondemand/minecraftondemand.py b/minecraftondemand/minecraftondemand.py new file mode 100644 index 0000000..2f3589f --- /dev/null +++ b/minecraftondemand/minecraftondemand.py @@ -0,0 +1,25 @@ +import time + +from mcrcon import MCRcon + +IP = '127.0.0.1' +PASS = 'jean-qot' + +empty_count = 0 + +def check_empty(): + with MCRcon(IP, PASS) as mcr: + resp = mcr.command('/list') + return 'There are 0 of a max' in resp + +while True: + if check_empty(): + empty_count += 1 + else: + empty_count = 0 + + if empty_count >= 15: + print('shutdown server!') + break + + time.sleep(60) diff --git a/minecraftondemand/requirements.txt b/minecraftondemand/requirements.txt new file mode 100644 index 0000000..1179808 --- /dev/null +++ b/minecraftondemand/requirements.txt @@ -0,0 +1,2 @@ +mcrcon==0.5.2 +pkg-resources==0.0.0 diff --git a/pychunkgen/pychunkgen.py b/pychunkgen/pychunkgen.py new file mode 100644 index 0000000..36fc60d --- /dev/null +++ b/pychunkgen/pychunkgen.py @@ -0,0 +1,50 @@ +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() diff --git a/pychunkgen/requirements.txt b/pychunkgen/requirements.txt new file mode 100644 index 0000000..1179808 --- /dev/null +++ b/pychunkgen/requirements.txt @@ -0,0 +1,2 @@ +mcrcon==0.5.2 +pkg-resources==0.0.0