Skip to content

Instantly share code, notes, and snippets.

@uktechreviews
Last active July 30, 2017 13:07
Show Gist options
  • Save uktechreviews/f1579e370fd659f71a5c521483c2d05f to your computer and use it in GitHub Desktop.
Save uktechreviews/f1579e370fd659f71a5c521483c2d05f to your computer and use it in GitHub Desktop.
import time
import mcpi.minecraft as minecraft
import mcpi.block as block
import random
import math
mc=minecraft.Minecraft.create()
safe = False
while safe == False:
x = random.randint(0,100)
z = random.randint(0,100)
y = mc.getHeight(x,z)
topBlock = mc.getBlock(x,y-1,z)
if topBlock !=block.WATER.id:
safe = True
mc.setBlock(x,y,z,block.WOOL.id,2)
found = False
while found == False:
player = mc.player.getTilePos()
xDist = x-player.x
yDist = y-player.y
zDist = z-player.z
vDist = math.sqrt(xDist**2 + zDist**2)
if vDist <=1:
mc.postToChat("You Found it")
time.sleep(2)
mc.setBlock(x,y,z,block.AIR.id)
found == True
else:
mc.postToChat("Distance" + str(math.floor(vDist)))
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment