adding entrance

This commit is contained in:
Eclairsombre
2024-06-12 13:10:59 +02:00
parent 5051071d1d
commit 6cd1bab14f
2 changed files with 372 additions and 4 deletions

149
House.py
View File

@@ -8,7 +8,7 @@ import math
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
class House: class House:
def __init__(self, editor, coordinates_min, coordinates_max): def __init__(self, editor, coordinates_min, coordinates_max, direction):
self.editor = editor self.editor = editor
self.coordinates_min = coordinates_min self.coordinates_min = coordinates_min
self.coordinates_max = coordinates_max self.coordinates_max = coordinates_max
@@ -17,11 +17,12 @@ class House:
size = [(coordinates_max[i] - coordinates_min[i]) + 10 for i in range(3)] size = [(coordinates_max[i] - coordinates_min[i]) + 10 for i in range(3)]
# Créer le tableau
self.grid3d = np.zeros(size, dtype=[('bool', bool), ('int', int)]) self.grid3d = np.zeros(size, dtype=[('bool', bool), ('int', int)])
self.nbEtage = (coordinates_max[1] - coordinates_min[1]) // 5 self.nbEtage = (coordinates_max[1] - coordinates_min[1]) // 5
self.direction = direction
def createHouseSkeleton(self): def createHouseSkeleton(self):
self.delete() self.delete()
@@ -143,6 +144,7 @@ class House:
def getAdjacentWalls(self): def getAdjacentWalls(self):
main_rect = self.skeleton[0] main_rect = self.skeleton[0]
x_main, z_main, width_main, depth_main, heigt_main = main_rect x_main, z_main, width_main, depth_main, heigt_main = main_rect
adjacent_walls = [] adjacent_walls = []
@@ -236,6 +238,33 @@ class House:
x_plan3d = x - self.coordinates_min[0] x_plan3d = x - self.coordinates_min[0]
z_plan3d = z - self.coordinates_min[2] z_plan3d = z - self.coordinates_min[2]
print(width, depth, n)
if width < depth:
if n==1:
for i in range(-1,depth+1):
self.editor.placeBlock((x+width//2, self.coordinates_max[1], z+i), Block("blackstone"))
else:
for k in range(n):
for i in range(-1, width+1):
for y in range(-1, depth//2+1):
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone"))
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone"))
else:
if n==1:
for i in range(-1,width+1):
self.editor.placeBlock((x+i, self.coordinates_max[1], z+depth//2), Block("blackstone"))
else:
for k in range(n-1):
for i in range(-1, width+1):
for y in range(-1, depth//2+1):
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+2), Block("blackstone"))
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone"))
print('-----------------------------------')
for i in range(-1, width+1): for i in range(-1, width+1):
for j in range(-1, depth+1): for j in range(-1, depth+1):
if width<depth: if width<depth:
@@ -246,14 +275,18 @@ class House:
if j== -1 : if j== -1 :
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1]: if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j-1), Block("quartz_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j-1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1]: if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j-1), Block("quartz_slab",{"type":"top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j-1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1] = True
elif j == depth: elif j == depth:
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1]: if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j+1), Block("quartz_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j+1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1]: if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j+1), Block("quartz_slab",{"type":"top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j+1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1] = True
else: else:
if depth%2 != 0: if depth%2 != 0:
@@ -263,14 +296,18 @@ class House:
if i== -1 : if i== -1 :
if not self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j]: if not self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"})) self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j]: if not self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"})) self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j] = True
elif i == width: elif i == width:
if not self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j]: if not self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"})) self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j]: if not self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"})) self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j] = True
if width<depth: if width<depth:
@@ -288,9 +325,13 @@ class House:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block")) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block")) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth: elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block")) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block")) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else: else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
@@ -307,11 +348,21 @@ class House:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth: elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else: else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
@@ -324,15 +375,25 @@ class House:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1]: if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1]: if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
elif j == depth: elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1]: if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1]: if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
if i != -1: if i != -1:
h += 0.5 h += 0.5
else: else:
@@ -351,9 +412,15 @@ class House:
if j == -1 : if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_block")) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block")) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ depth-1-i] = True
elif j == width: elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_block")) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block")) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ depth-1-i] = True
else: else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
@@ -371,11 +438,21 @@ class House:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
elif j == width: elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
else: else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"}))
@@ -388,15 +465,25 @@ class House:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]: if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]: if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
elif j == width: elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]: if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]: if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"})) self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True self.grid3d[ j, round(height+h), i] = True
@@ -406,7 +493,6 @@ class House:
if i != -1: if i != -1:
h += 0.5 h += 0.5
QUARTZ_SLAB = Block("quartz_slab", {"type": "top"}) QUARTZ_SLAB = Block("quartz_slab", {"type": "top"})
@@ -423,6 +509,7 @@ class House:
self.editor.placeBlock((x + i, self.coordinates_max[1]-1, z + j), QUARTZ_SLAB) self.editor.placeBlock((x + i, self.coordinates_max[1]-1, z + j), QUARTZ_SLAB)
def putCelling(self): def putCelling(self):
for k in range(0, len(self.skeleton)): for k in range(0, len(self.skeleton)):
@@ -442,6 +529,58 @@ class House:
self.grid3d[ x_plan3d+i, 4*y, z_plan3d+j] = True self.grid3d[ x_plan3d+i, 4*y, z_plan3d+j] = True
def placeWindow(self):
pass
def placeStairs(self):
pass
def WallFacingDirection(self):
if self.direction == "N":
closest_wall = min(self.skeleton, key=lambda wall: wall[1])
wall = (closest_wall[0], closest_wall[1], closest_wall[0] + closest_wall[2], closest_wall[1])
elif self.direction == "S":
closest_wall = max(self.skeleton, key=lambda wall: wall[1] + wall[3])
wall = (closest_wall[0], closest_wall[1] + closest_wall[3], closest_wall[0] + closest_wall[2], closest_wall[1] + closest_wall[3])
elif self.direction == "E":
closest_wall = max(self.skeleton, key=lambda wall: wall[0] + wall[2])
wall = (closest_wall[0] + closest_wall[2], closest_wall[1], closest_wall[0] + closest_wall[2], closest_wall[1] + closest_wall[3])
elif self.direction == "W":
closest_wall = min(self.skeleton, key=lambda wall: wall[0])
wall = (closest_wall[0], closest_wall[1], closest_wall[0], closest_wall[1] + closest_wall[3])
else:
return []
if wall != self.skeleton[0]:
wall = (wall[0]+1, wall[1]+1, wall[2]-2, wall[3]-2)
return wall
def placeEntrance(self):
wall = self.WallFacingDirection()
match self.direction:
case "N":
if (wall[2] - wall[0]) % 2 != 0:
self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[1]-1), Block("air"))
self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+2, wall[1]-1), Block("air"))
print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1])
self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]-1), Block("air"))
self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+2, wall[1]-1), Block("air"))
print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[1]+1)
case "S":
pass
case "E":
pass
case "W":
pass
case _:
pass
if __name__ == "__main__": if __name__ == "__main__":
editor = Editor(buffering=True) editor = Editor(buffering=True)
buildArea = editor.getBuildArea() buildArea = editor.getBuildArea()
@@ -450,7 +589,8 @@ if __name__ == "__main__":
for i in range(1): for i in range(1):
house = House(editor, coordinates_min, coordinates_max) house = House(editor, coordinates_min, coordinates_max,"N")
house.createHouseSkeleton() house.createHouseSkeleton()
house.putWallOnSkeleton() house.putWallOnSkeleton()
print("House n°", i+1, "created") print("House n°", i+1, "created")
@@ -459,6 +599,7 @@ if __name__ == "__main__":
house.placeDoor() house.placeDoor()
house.placeRoof() house.placeRoof()
house.putCelling() house.putCelling()
house.placeEntrance()
new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_min =(coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2])
new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2]) new_coordinates_max = (coordinates_max[0] + 10 +24, coordinates_max[1], coordinates_max[2])

227
temp.py Normal file
View File

@@ -0,0 +1,227 @@
for i in range(-1, width+1):
for j in range(-1, depth+1):
if width<depth:
if width%2 != 0:
if (i == width//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
if j== -1 :
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j-1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j-1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1] = True
elif j == depth:
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j+1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j+1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1] = True
else:
if depth%2 != 0:
if (j == depth//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
if i== -1 :
if not self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j] = True
elif i == width:
if not self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j] = True
if width<depth:
h = 0
for i in range(-1, width//2):
for j in range(-1, depth+1):
if i != -1:
if h % 1 == 0:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"top"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-0.5, z + j), Block("C"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-0.5, z + j), Block("blackstone"))
self.grid3d[ x_plan3d+ i, round(height+h+0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h+0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ i, round(height+h-0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-0.5), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
if i != -1:
h += 0.5
else:
h = 0
for i in range(-1, depth//2):
for j in range(-1, width+1):
if i != -1:
if h % 1 == 0:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"top"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"top"}))
self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ depth-1-i] = True
else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + i), Block("blackstone"))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + depth-1-i), Block("blackstone"))
self.grid3d[ j, round(height+h+0.5), i] = True
self.grid3d[ j, round(height+h+0.5), depth-1-i] = True
self.grid3d[ j, round(height+h-0.5), i] = True
self.grid3d[ j, round(height+h-0.5), depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
if i != -1:
h += 0.5