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
40
41
42
43
44
|
import mcpi.block
from BerryClient.commands import command
from BerryClient.models.House import House
MATERIAL_MAPPING = {
"air": mcpi.block.AIR,
"stone": mcpi.block.STONE,
"brick": mcpi.block.BRICK_BLOCK,
}
class BlockWorld:
def __init__(self, core):
self.core = core
def set_block(self, x, y, z, block):
pos = (x, y, z)
block_obj = MATERIAL_MAPPING[block]
self.core.setBlock(*pos, block_obj.id)
def set_blocks(self, x1, y1, z1, x2, y2, z2, block):
pos1 = (x1, y1, z1)
pos2 = (x2, y2, z2)
block_obj = MATERIAL_MAPPING[block]
self.core.setBlocks(*pos1, *pos2, block_obj.id)
def player_position(self) -> tuple:
return self.core.player.getPos()
def __getattr__(self, attr):
return getattr(self.core, attr)
@command()
def b(core):
"""
Builds a house
"""
bw = BlockWorld(core)
h = House(bw.player_position(), bw)
h.build()
|