-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminecraft-building.js
74 lines (68 loc) · 2.37 KB
/
minecraft-building.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//Materials
let stone = blocks.block(Block.Stone)
let brick = blocks.block(Block.Bricks)
player.onChatCommand("build", [], ({ }) => {
builder.teleportTo(player.position())
builder.move(SixDirection.Forward, 10)
buildBuilding(stone, 3, 5, 2, 3)
})
//Build block of flats with chosen height, width, windows height and roofType
//Roof types:
//0-flat roof, 1-flat with balcony, 2-"pyramid" roof
function buildBuilding(blocktype: number, height: number, width: number, windowsHeight: number, roofType: number){
for (let index = 0; index <= height; index++) {
buildfloor(blocktype, width)
buildWindows(windowsHeight, width)
}
buildRoof(blocktype, width, roofType)
}
function buildfloor(blocktype: number, floorWidth: number) {
builder.setOrigin()
builder.mark()
builder.shift(floorWidth, 0, floorWidth)
builder.fill(blocktype)
builder.teleportToOrigin()
builder.move(SixDirection.Up, 1)
}
function buildWindows(winHeigt: number, winWidth: number) {
for (let i = 0; i < winHeigt; i++) {
for (let j = 0; j < winWidth; j++) {
builder.mark()
builder.move(SixDirection.Forward, winWidth)
builder.line(blocks.block(Block.Glass))
builder.turn(TurnDirection.Left)
}
builder.move(SixDirection.Up, 1)
}
}
function buildRoof(blocktype: number, roofWidth: number, roofType: number){
if((roofType == 0) || (roofType == 1) ){
builder.setOrigin()
builder.mark()
builder.shift(roofWidth, 0, roofWidth)
builder.fill(blocktype)
builder.teleportToOrigin()
if(roofType == 1){
builder.move(SixDirection.Up, 1)
for (let i = 1; i < roofWidth; i++) {
builder.mark()
builder.move(SixDirection.Forward, roofWidth)
builder.line(blocks.block(Block.OakFence))
builder.turn(TurnDirection.Left)
}
}
}
if(roofType ==2 ){
let newWidth = roofWidth
for (let i = 0; i < roofWidth - 1; i++) {
for (let j = 0; j < roofWidth; j++) {
builder.mark()
builder.move(SixDirection.Forward, newWidth)
builder.line(blocks.block(Block.IronBlock))
builder.turn(TurnDirection.Left)
}
builder.shift(1, 1, 1)
newWidth = newWidth - 2
}
}
}