This commit is contained in:
Eclairsombre
2024-06-15 14:31:48 +02:00
parent b90a0128b2
commit 59339a46db

481
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, direction): def __init__(self, editor, coordinates_min, coordinates_max, direction, list_block):
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
@@ -25,20 +25,31 @@ class House:
self.entranceWall = None self.entranceWall = None
self.blocks = list_block
self.entranceCo = None
self.wall = Block(list_block["wall"])
self.roof = Block(list_block["roof"])
self.roof_slab = Block(list_block["roof_slab"])
self.door = Block(list_block["door"])
self.window = Block(list_block["window"])
self.entrance = Block(list_block["entrance"])
self.stairs = Block(list_block["stairs"])
self.celling = Block(list_block["celling"])
self.floor = Block(list_block["floor"])
self.celling_slab = Block(list_block["celling_slab"])
self.gardenOutline = Block(list_block["garden_outline"])
self.garden_floor = Block(list_block["garden_floor"])
def createHouseSkeleton(self): def createHouseSkeleton(self):
self.delete() self.delete()
x_min, y_min, z_min = self.coordinates_min x_min, y_min, z_min = self.coordinates_min
x_max, y_max, z_max = self.coordinates_max x_max, y_max, z_max = self.coordinates_max
for i in range (x_min, x_max):
for y in range(z_min, z_max):
if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1:
self.editor.placeBlock((i, y_min, y), Block("oak_planks"))
perimeter_width = x_max - x_min perimeter_width = x_max - x_min
perimeter_depth = z_max - z_min perimeter_depth = z_max - z_min
@@ -63,13 +74,12 @@ class House:
for i in range(0, width-1): for i in range(0, width-1):
for j in range(0, depth-1): for j in range(0, depth-1):
self.editor.placeBlock((x + i, y_min, z + j), Block("stone")) self.editor.placeBlock((x + i, y_min, z + j), self.floor)
self.grid[x+i,z+j] = True,1 self.grid[x+i,z+j] = True,1
self.grid3d[x_plan3d+i,0,z_plan3d+j] = True,1 self.grid3d[x_plan3d+i,0,z_plan3d+j] = True,1
self.skeleton.append((x, z, width-1, depth-1, height)) self.skeleton.append((x, z, width-1, depth-1, height))
print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1)) print("Coordinates of the corners: ", (x, z), (x, z+depth-1), (x+width-1, z), (x+width-1, z+depth-1))
block = ["redstone_block", "gold_block", "diamond_block"]
x_min -= 1 x_min -= 1
x_max -= 1 x_max -= 1
@@ -109,7 +119,7 @@ class House:
if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1: if i == 0 or i == new_width-1 or j == 0 or j == new_depth-1:
continue continue
else: else:
self.editor.placeBlock((new_x + i, y_min, new_z + j), Block(block[_])) self.editor.placeBlock((new_x + i, y_min, new_z + j), self.floor)
self.skeleton.append((new_x, new_z, new_width, new_depth, height)) self.skeleton.append((new_x, new_z, new_width, new_depth, height))
break break
@@ -140,7 +150,7 @@ class House:
for y in range(0, height): for y in range(0, height):
if i == -1 or i == width or j == -1 or j == depth: if i == -1 or i == width or j == -1 or j == depth:
if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2): if not (self.grid[x + i, z + j]['bool']) and not (self.grid[x + i, z + j]['int'] == 1) or (self.grid[x + i, z + j]['bool'] and self.grid[x + i, z + j]['int'] == 2):
self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), Block("stone")) self.editor.placeBlock((x + i, self.coordinates_min[1] + y, z + j), self.wall)
self.grid3d[ x_plan3d+i, y, z_plan3d+j] = True self.grid3d[ x_plan3d+i, y, z_plan3d+j] = True
#print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int']) #print( i, y, j, self.grid[x + i, z + j]['bool'],self.grid[x + i, z + j]['int'])
@@ -250,26 +260,26 @@ class House:
for k in range(n-1): for k in range(n-1):
for i in range(-1, depth+1): for i in range(-1, depth+1):
for y in range(-1, width//2+1): for y in range(-1, width//2+1):
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+3), Block("blackstone")) self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+y+k+3), self.roof)
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-4-k), Block("blackstone")) self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-4-k), self.roof)
if width%2 == 0: if width%2 == 0:
for i in range(-1, depth+1): for i in range(-1, depth+1):
self.editor.placeBlock((x+width//2+1, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) self.editor.placeBlock((x+width//2+1, self.coordinates_max[1]+n-1, z+i), self.roof)
for i in range(-1,depth+1): for i in range(-1,depth+1):
self.editor.placeBlock((x+width//2, self.coordinates_max[1]+n-1, z+i), Block("blackstone")) self.editor.placeBlock((x+width//2, self.coordinates_max[1]+n-1, z+i), self.roof)
else: else:
if n>1: if n>1:
for k in range(n-1): for k in range(n-1):
for i in range(-1, width+1): for i in range(-1, width+1):
for y in range(-1, depth//2+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+y+k+2), self.roof)
self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), Block("blackstone")) self.editor.placeBlock((x + i, self.coordinates_max[1]+k, z+depth-y-3-k), self.roof)
if depth%2 == 0: if depth%2 == 0:
for i in range(-1, width+1): for i in range(-1, width+1):
self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2+1), Block("blackstone")) self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2+1), self.roof)
for i in range(-1,width+1): for i in range(-1,width+1):
self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2), Block("blackstone")) self.editor.placeBlock((x+i, self.coordinates_max[1]+n-1, z+depth//2), self.roof)
print('-----------------------------------') print('-----------------------------------')
@@ -278,43 +288,43 @@ class House:
if width<depth: if width<depth:
if width%2 != 0: if width%2 != 0:
if (i == width//2 ): if (i == width//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block(self.blocks["roof_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
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(self.blocks["celling_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1] = True 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(self.blocks["celling_slab"],{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1] = True 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(self.blocks["celling_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1] = True 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(self.blocks["celling_slab"],{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1] = True self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1] = True
else: else:
if depth%2 != 0: if depth%2 != 0:
if (j == depth//2 ): if (j == depth//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"})) self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block(self.blocks["roof_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
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(self.blocks["celling_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j] = True 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(self.blocks["celling_slab"],{"type":"top"}))
self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j] = True 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(self.blocks["celling_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j] = True 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(self.blocks["celling_slab"],{"type":"top"}))
self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j] = True self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j] = True
if width<depth: if width<depth:
@@ -324,27 +334,27 @@ class House:
for j in range(-1, depth+1): for j in range(-1, depth+1):
if i != -1: if i != -1:
if h % 1 == 0: 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 + i, self.coordinates_max[1]+h, z + j), Block(self.blocks["roof_slab"],{"type":"top"}))
self.editor.placeBlock((x + width-1-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(self.blocks["roof_slab"],{"type":"top"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True 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 self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 : if j == -1 :
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), self.celling)
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), self.celling)
self.grid3d[ x_plan3d+ i, round(height+h), 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 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), self.celling)
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), self.celling)
self.grid3d[ x_plan3d+ i, round(height+h), 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 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(self.blocks["roof_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(self.blocks["roof_slab"],{"type":"bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-0.5, z + j), Block("blackstone")) self.editor.placeBlock((x + i, self.coordinates_max[1]+h-0.5, z + j), self.roof)
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-0.5, z + j), Block("blackstone")) self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-0.5, z + j), self.roof)
self.grid3d[ x_plan3d+ 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 self.grid3d[ x_plan3d+ width-1-i, round(height+h+0.5), z_plan3d+ j] = True
@@ -352,52 +362,52 @@ class House:
self.grid3d[ x_plan3d+ width-1-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 : 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 + i, self.coordinates_max[1]+h, z + j -1), Block(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(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 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+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(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 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+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-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(self.blocks["roof_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(self.blocks["roof_slab"],{"type":"bottom"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True 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 self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 : 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 + i, self.coordinates_max[1]+h, z + j -1), Block(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1] = True 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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1] = True 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+ 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+ 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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1] = True 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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1] = True 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+ i, round(height+h-1), z_plan3d+ j+1] = True
@@ -411,30 +421,30 @@ class House:
for j in range(-1, width+1): for j in range(-1, width+1):
if i != -1: if i != -1:
if h % 1 == 0: 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 + i), Block(self.blocks["roof_slab"],{"type":"top"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"top"})) self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block(self.blocks["roof_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+ i] = True
self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ depth-1-i] = True self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ depth-1-i] = True
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 ), self.celling)
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 ), self.celling)
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ i] = True 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 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 ), self.celling)
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 ), self.celling)
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ i] = True 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 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(self.blocks["roof_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(self.blocks["roof_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 + i), self.roof)
self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + depth-1-i), Block("blackstone")) self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + depth-1-i), self.roof)
self.grid3d[ j, round(height+h+0.5), i] = True 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), depth-1-i] = True
@@ -442,52 +452,52 @@ class House:
self.grid3d[ j, round(height+h-0.5), depth-1-i] = True self.grid3d[ j, round(height+h-0.5), depth-1-i] = True
if j == -1 : 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 + i ), Block(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, round(height+h), 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), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, round(height+h), 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), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-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(self.blocks["roof_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(self.blocks["roof_slab"],{"type":"bottom"}))
self.grid3d[ j, round(height+h), 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), depth-1-i] = True
if j == -1 : 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 + i ), Block(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True 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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), 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), 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(self.blocks["celling_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(self.blocks["celling_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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True 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(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True self.grid3d[ j, round(height+h), i] = True
@@ -501,7 +511,7 @@ class House:
if i != -1: if i != -1:
h += 0.5 h += 0.5
QUARTZ_SLAB = Block("quartz_slab", {"type": "top"}) QUARTZ_SLAB = Block(self.blocks["celling_slab"], {"type": "top"})
for i in range(-2, width+2): for i in range(-2, width+2):
@@ -533,24 +543,10 @@ class House:
for y in range(1,self.nbEtage+1): for y in range(1,self.nbEtage+1):
for i in range(0, width): for i in range(0, width):
for j in range(0, depth): for j in range(0, depth):
self.editor.placeBlock((x + i, self.coordinates_min[1] +4*y, z + j), Block("quartz_block")) self.editor.placeBlock((x + i, self.coordinates_min[1] +4*y, z + j), self.celling)
self.grid3d[ x_plan3d+i, 4*y, z_plan3d+j] = True self.grid3d[ x_plan3d+i, 4*y, z_plan3d+j] = True
def getNonAdjacentWalls(self):
main_rect = self.skeleton[0]
x_main, z_main, width_main, depth_main, height_main = main_rect
non_adjacent_walls = []
for k in range(1, len(self.skeleton)):
x, z, width, depth, height = self.skeleton[k]
walls = [(x, z, x + width - 1, z), (x, z, x, z + depth - 1), (x, z + depth - 1, x + width - 1, z + depth - 1), (x + width - 1, z, x + width - 1, z + depth - 1)]
for wall in walls:
x1, z1, x2, z2 = wall
if not ((x_main <= x1 <= x_main + width_main or x_main <= x2 <= x_main + width_main) and (z_main - 1 == z1 or z_main + depth_main + 1 == z1)) and not ((z_main <= z1 <= z_main + depth_main or z_main <= z2 <= z_main + depth_main) and (x_main - 1 == x1 or x_main + width_main + 1 == x1)):
non_adjacent_walls.append((x1, z1, x2, z2))
print(non_adjacent_walls)
return non_adjacent_walls
def getAllExterneWalls(self): def getAllExterneWalls(self):
walls = [] walls = []
@@ -595,54 +591,44 @@ class House:
if axis%2==0: if axis%2==0:
if axis == 4: if axis == 4:
if is_x: if is_x:
self.editor.placeBlock((wall[0]+2, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+2, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
self.editor.placeBlock((wall[0]+3, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+3, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
else: else:
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+3), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+3), self.window)
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2), self.window)
else: else:
for i in range(0, math.ceil(axis/4)): for i in range(0, math.ceil(axis/4)):
if is_x: if is_x:
self.editor.placeBlock((wall[0]+1+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+1+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
self.editor.placeBlock((wall[0]+2+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+2+i*4, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
else: else:
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i*4), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i*4), self.window)
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2+i*4), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+2+i*4), self.window)
else: else:
if axis<=5: if axis<=5:
for i in range(0, axis): for i in range(0, axis):
if is_x: if is_x:
self.editor.placeBlock((wall[0]+1+i, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+1+i, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
else: else:
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+1+i), self.window)
else: else:
for i in range(0, math.ceil(axis/2)): for i in range(0, math.ceil(axis/2)):
if is_x: if is_x:
self.editor.placeBlock((wall[0]+i*2+1, self.coordinates_min[1] + 2+l*4, wall[1]), Block("glass_pane")) self.editor.placeBlock((wall[0]+i*2+1, self.coordinates_min[1] + 2+l*4, wall[1]), self.window)
else: else:
self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+i*2+1), Block("glass_pane")) self.editor.placeBlock((wall[0], self.coordinates_min[1] + 2+l*4, wall[1]+i*2+1), self.window)
def placeWindow(self): def placeWindow(self):
walls = self.getAllExterneWalls() walls = self.getAllExterneWalls()
for wall in walls: for wall in walls:
x1, z1, x2, z2 = wall x1, z1, x2, z2 = wall
x = abs(x2-x1) -1 x = abs(x2-x1) -1
z = abs(z2-z1) -1 z = abs(z2-z1) -1
if x1 == x2: if x1 == x2:
self.placeWindowOnWall(wall, z, False) self.placeWindowOnWall(wall, z, False)
elif z1 == z2: elif z1 == z2:
self.placeWindowOnWall(wall, x, True) self.placeWindowOnWall(wall, x, True)
def placeStairs(self): def placeStairs(self):
pass pass
@@ -665,53 +651,207 @@ class House:
return [] return []
if closest_wall != self.skeleton[0]: if closest_wall != self.skeleton[0]:
if wall[0] == wall[2]:
wall = (wall[0]+1, wall[1]+1, wall[2]-2, wall[3]-2) wall = (wall[0]-1, wall[1]+1, wall[2]-1, wall[3]-2)
elif wall[1] == wall[3]:
wall = (wall[0]+1, wall[1]-1, wall[2]-2, wall[3]-1)
else: else:
wall = (wall[0], wall[1], wall[2]-1, wall[3]-1) if wall[0] == wall[2]:
if self.direction == "W":
wall = (wall[0]-2, wall[1], wall[2]-2, wall[3])
else:
wall = (wall[0], wall[1]+1, wall[2], wall[3]-2)
elif wall[1] == wall[3]:
if self.direction == "N":
wall = (wall[0]+1, wall[1]-2, wall[2]-2, wall[3]-2)
else:
wall = (wall[0]+1, wall[1], wall[2]-2, wall[3])
return wall return wall
def placeEntrance(self): def placeEntrance(self):
wall = self.WallFacingDirection() wall = self.WallFacingDirection()
print(wall)
self.entranceWall = wall self.entranceWall = wall
match self.direction: 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 +1, self.coordinates_min[1]+1, wall[1]-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":
if (wall[2] - wall[0]) % 2 != 0:
self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[3]+1), Block("air"))
self.editor.placeBlock(((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+2, wall[3]+1), Block("air"))
print((wall[0] + wall[2]) // 2 +1, self.coordinates_min[1]+1, wall[3]+1)
self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[3]+1), Block("air"))
self.editor.placeBlock(((wall[0] + wall[2]) // 2, self.coordinates_min[1]+2, wall[3]+1), Block("air"))
print((wall[0] + wall[2]) // 2, self.coordinates_min[1]+1, wall[3]+1)
case "E":
if (wall[3] - wall[1]) % 2 != 0:
self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air"))
self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air"))
print(wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1)
self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[2]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
print(wall[2]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2)
case "W": case "W":
if (wall[3] - wall[1]) % 2 != 0: if (wall[3] - wall[1]) % 2 != 0:
self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air")) self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air"))
self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air")) self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air"))
print(wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1) self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air")) self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0]-1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
print(wall[0]-1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2) self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 +2), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +2), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.entranceCo = ((wall[1] + wall[3]) // 2, (wall[1] + wall[3]) // 2 +2, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 -1)
else:
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1], (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.entranceCo = ((wall[1] + wall[3] )// 2, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 -1)
case "N":
if (wall[2] - wall[0]) % 2 != 0:
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+1, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+2, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+1, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+2, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +2, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +2, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.entranceCo = (wall[0] + (wall[2] - wall[0]) // 2, wall[0] + (wall[2] - wall[0]) // 2 +2, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 -1)
else:
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+1, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+2, wall[1]+1), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1], wall[1]), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1]+3, wall[1]), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.entranceCo = (wall[0] + (wall[2] - wall[0]) // 2, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 -1)
case "E":
if (wall[3] - wall[1]) % 2 != 0:
self.editor.placeBlock((wall[0], self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2 +1), Block("air"))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2 +1), Block("air"))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 +2), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +2), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.entranceCo = ((wall[1] + wall[3]) // 2, (wall[1] + wall[3]) // 2 +2, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 -1)
else:
self.editor.placeBlock((wall[0], self.coordinates_min[1]+1, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0], self.coordinates_min[1]+2, (wall[1] + wall[3]) // 2), Block("air"))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1], (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 ), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 +1 ), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.editor.placeBlock((wall[0]+1, self.coordinates_min[1]+3, (wall[1] + wall[3]) // 2 -1), Block(self.blocks["stairs"], {"facing": "south", "half": "top"}))
self.entranceCo = ((wall[1] + wall[3]) // 2, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 +1, (wall[1] + wall[3]) // 2 -1)
case "S":
print(wall)
if (wall[2] - wall[0]) % 2 != 0:
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+1, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+2, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+1, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+2, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +2, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +2, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.entranceCo = (wall[0] + (wall[2] - wall[0]) // 2, wall[0] + (wall[2] - wall[0]) // 2 +2, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 -1)
else:
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+1, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+2, wall[1]), Block("air"))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "north"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "west"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1], wall[1]+1), Block(self.blocks["stairs"], {"facing": "east"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "north", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 +1, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "west", "half": "top"}))
self.editor.placeBlock((wall[0] + (wall[2] - wall[0]) // 2 -1, self.coordinates_min[1]+3, wall[1]+1), Block(self.blocks["stairs"], {"facing": "east", "half": "top"}))
self.entranceCo = (wall[0] + (wall[2] - wall[0]) // 2, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 +1, wall[0] + (wall[2] - wall[0]) // 2 -1)
case _: case _:
pass pass
def placeGardenOutline(self):
x_min, y_min, z_min = self.coordinates_min
x_max, y_max, z_max = self.coordinates_max
for i in range (x_min, x_max):
for y in range(z_min, z_max):
if i == x_min or i == x_max - 1 or y == z_min or y == z_max - 1 :
match self.direction:
case "N":
if not (i in self.entranceCo and y == z_min):
self.editor.placeBlock((i, y_min-1, y), Block("oak_log"))
self.editor.placeBlock((i, y_min, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+1, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+2, y), self.gardenOutline)
case "S":
if not (i in self.entranceCo and y == z_max-1):
self.editor.placeBlock((i, y_min-1, y), Block("oak_log"))
self.editor.placeBlock((i, y_min, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+1, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+2, y), self.gardenOutline)
case "E":
if not (i == x_max-1 and y in self.entranceCo):
self.editor.placeBlock((i, y_min-1, y), Block("oak_log"))
self.editor.placeBlock((i, y_min, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+1, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+2, y), self.gardenOutline)
case "W":
if not (i == x_min and y in self.entranceCo):
self.editor.placeBlock((i, y_min-1, y), Block("oak_log"))
self.editor.placeBlock((i, y_min, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+1, y), self.gardenOutline)
self.editor.placeBlock((i, y_min+2, y), self.gardenOutline)
else:
print(i, y)
case _:
self.editor.placeBlock((i, y_min-1, y), self.garden_floor)
else:
self.editor.placeBlock((i, y_min-1, y), self.garden_floor)
if __name__ == "__main__": if __name__ == "__main__":
editor = Editor(buffering=True) editor = Editor(buffering=True)
@@ -719,9 +859,23 @@ if __name__ == "__main__":
coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)] coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)]
coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)] coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)]
blocks = {
"wall": "blackstone",
"roof": "blackstone",
"roof_slab": "blackstone_slab",
"door": "oak_door",
"window": "glass_pane",
"entrance": "oak_door",
"stairs": "quartz_stairs",
"celling": "quartz_block",
"floor": "quartz_block",
"celling_slab": "quartz_slab",
"garden_outline": "oak_leaves",
"garden_floor": "grass_block"
}
for i in range(1): for i in range(1):
house = House(editor, coordinates_min, coordinates_max,"N") house = House(editor, coordinates_min, coordinates_max,"W", blocks)
house.createHouseSkeleton() house.createHouseSkeleton()
house.putWallOnSkeleton() house.putWallOnSkeleton()
@@ -734,6 +888,7 @@ if __name__ == "__main__":
house.placeWindow() house.placeWindow()
house.placeEntrance() house.placeEntrance()
house.placeGardenOutline()
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])