-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovingBlock.py
More file actions
41 lines (30 loc) · 821 Bytes
/
movingBlock.py
File metadata and controls
41 lines (30 loc) · 821 Bytes
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
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
import time
def calculateMove():
global x
global y
global z
currentHeight = mc.getHeight(x, z)- 1
forwardHeight = mc.getHeight(x + 1, z)
rightHeight = mc.getHeight(x,z + 1)
backwardHeight = mc.getHeight( x - 1, z)
leftHeight = mc.getHeight(x, z - 1)
if forwardHeight - currentHeight < 3:
x += 1
elif rightHeight - currentHeight < 3:
z += 1
elif leftHeight - currentHeight < 3:
z -= 1
elif backwardHeight - currentHeight < 3:
x -= 1
y = mc.getHeight(x, z)
pos = mc.player.getTilePos()
x = pos.x
z = pos.z
y = mc.getHeight(x,z)
while True:
calculateMove()
mc.setBlock(x, y, z, 103)
time.sleep(1)
mc.setBlock(x, y, z, 0)