-
Notifications
You must be signed in to change notification settings - Fork 0
/
esconde_esconde.py
64 lines (56 loc) · 2.69 KB
/
esconde_esconde.py
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
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import random
import math
def roundVec3(vec3):
return minecraft.Vec3(int(vec3.x), int(vec3.y), int(vec3.z))
def distanceBetweenPoints(point1, point2):
xd = point2.x - point1.x
yd = point2.y - point1.y
zd = point2.z - point1.z
return math.sqrt((xd*xd) + (yd*yd) + (zd*zd))
def verticaldistance(point1, point2):
yd = point2.y - point1.y
if yd < 0:
return "pra baixo " + str(int(abs(yd)))
else:
return "pra cima " + str(int(abs(yd)))
if __name__ == "__main__":
mc = minecraft.Minecraft.create()
mc.postToChat("oi Pedro!! Vamos brincar???")
time.sleep(2)
mc.postToChat("eu escondi um diamante, voce consegue encontrar?")
time.sleep(2)
while True:
playerPos = mc.player.getPos()
randomBlockPos = roundVec3(playerPos)
randomBlockPos.x = random.randrange(max(-127,randomBlockPos.x - 50), min(127,randomBlockPos.x + 50))
randomBlockPos.y = random.randrange(randomBlockPos.y - 5, randomBlockPos.y + 5)
randomBlockPos.z = random.randrange(max(-127,randomBlockPos.x - 50), min(127,randomBlockPos.x + 50))
print(randomBlockPos)
mc.setBlocks(randomBlockPos.x-1, randomBlockPos.y-1, randomBlockPos.z-1,randomBlockPos.x+1, randomBlockPos.y+1, randomBlockPos.z+1, block.DIAMOND_BLOCK)
mc.postToChat("Pronto! Pode ir procurar!")
seeking = True
lastPlayerPos = playerPos
lastDistanceFromBlock = distanceBetweenPoints(randomBlockPos, lastPlayerPos)
timeStarted = time.time()
while (seeking == True):
playerPos = mc.player.getPos()
if lastPlayerPos != playerPos:
distanceFromBlock = distanceBetweenPoints(randomBlockPos, playerPos)
if distanceFromBlock < 14:
mc.postToChat(verticaldistance(randomBlockPos, playerPos))
if distanceFromBlock < 5:
seeking = False
else:
if distanceFromBlock < lastDistanceFromBlock:
mc.postToChat("Ta quente " + str(int(distanceFromBlock)))
if distanceFromBlock > lastDistanceFromBlock:
mc.postToChat("Ta frio " + str(int(distanceFromBlock)))
lastDistanceFromBlock = distanceFromBlock
time.sleep(2)
timeTaken = time.time() - timeStarted
mc.postToChat("Muito bem, cara!! Demorou so - " + str(int(timeTaken)) + " segundos.")
time.sleep(5)
mc.setBlocks(randomBlockPos.x-2, randomBlockPos.y-2, randomBlockPos.z-2,randomBlockPos.x+2, randomBlockPos.y+2, randomBlockPos.z+2, 0)