Last active
July 30, 2017 13:07
-
-
Save uktechreviews/f1579e370fd659f71a5c521483c2d05f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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