Created
August 3, 2017 11:21
-
-
Save uktechreviews/e4b7847f71323f8520bdbf1bb444e416 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 | |
from gpiozero import Button | |
mc=minecraft.Minecraft.create() | |
button = Button(21) | |
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() | |
if button.is_pressed: | |
mc.postToChat("Flare ignited") | |
add = 2 | |
while add<20: | |
mc.setBlock(x,y+add,z,block.WOOL.id,4) | |
time.sleep(0.1) | |
mc.setBlock(x,y+add,z,block.AIR) | |
add+=1 | |
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.TNT.id,1) | |
found == True | |
break | |
else: | |
mc.postToChat("Distance" + str(math.floor(vDist))) | |
time.sleep(2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment