-
Notifications
You must be signed in to change notification settings - Fork 0
/
support_util.py
39 lines (32 loc) · 1.48 KB
/
support_util.py
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
from gdpc.direct_interface import getBlock, runCommand
import requests
import pprint
from requests.exceptions import ConnectionError
def get_block_with_state(x, y, z):
"""**Return the block ID from the world**."""
url = f'http://localhost:9000/blocks?x={x}&y={y}&z={z}&includeState=true'
try:
response = requests.get(url).text
except ConnectionError:
return "minecraft:void_air"
return response
# all boundaries inclusive
def load_as_blueprint(house_area, house_level, house_level_max, house_level_base = -1):
blueprint = {}
size = [house_area[0, 1] - house_area[0, 0] + 1, house_area[1, 1] - house_area[1, 0] + 1, house_level_max - house_level + 1]
if house_level_base == -1:
house_level_base = house_level
for x in range(house_area[0, 0], house_area[0, 1] + 1):
for y in range(house_level_base, house_level_max + 1):
for z in range(house_area[1, 0], house_area[1, 1] + 1):
block = get_block_with_state(x, y, z)[10:]
# if block != 'air[]':
if True:
if block in blueprint:
blueprint[block].append((x - house_area[0, 0], y - house_level, z - house_area[1, 0]))
else:
blueprint[block] = [(x - house_area[0, 0], y - house_level, z - house_area[1, 0])]
pp = pprint.PrettyPrinter(depth = 4, width = 200, compact = True)
pp.pprint(blueprint)
print(size)
return blueprint