@qoderman/

Radar-1

Python

No description

fork
loading
Files
  • main.py
  • a
main.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
from mcpi.minecraft import Minecraft
import math
import time

# Function to calculate the distances
def calculateDistance(pos1, pos2):
  distance = math.sqrt(math.pow((pos1.x - pos2.x), 2) + math.pow((pos1.y - pos2.y), 2) + math.pow((pos1.z - pos2.z), 2))
  return (distance)


mc = Minecraft.create("m.ignitecs.org", 4711)

myUsername = "IgniteCS9"
otherUsernames = ["CodingMindsOne", "Ben", "Andy", "Michael", "Richard", "Shania", "Alex", "Athena"]
myId = mc.getPlayerEntityId(myUsername)

# otherId = mc.getPlayerEntityId(otherUsername)

while True:
  # Get our position
  myPos = mc.entity.getPos(myId)
  print(myPos)

  # Get other player position
  otherPos = mc.entity.getPos(otherId)
  print(otherPos)

  distance = calculateDistance(myPos, otherPos)

  mc.postToChat(myUsername + " <----> " + otherUsername + ": " + str(distance))

  time.sleep(2)