SHARE
TWEET

Untitled

a guest Feb 14th, 2020 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import mcpi.minecraft as minecraft
  2. import mcpi.block as block
  3. import time
  4. import random
  5. mc = minecraft.Minecraft.create()
  6. score = 0
  7. ECART = 10
  8. tresor_x = None
  9. tresor_y = None
  10. tresor_z = None
  11. def poserTresor():
  12.     global tresor_x, tresor_y, tresor_z
  13.     pos = mc.player.getTilePos()
  14.     tresor_x = random.randint(pos.x, pos.x+ECART)
  15.     tresor_y = random.randint(pos.y+2, pos.y+ECART)
  16.     tresor_z = random.randint(pos.z, pos.z+ECART)
  17.     mc.setBlock(tresor_x, tresor_y, tresor_z, block.DIAMOND_BLOCK.id)
  18.  
  19. def verifFrappe():
  20.     global score
  21.     global tresor_x
  22.     evenements = mc.events.pollBlockHits()
  23.     for e in evenements:
  24.         pos = e.pos
  25.         if pos.x == tresor_x and pos.y == tresor_y and pos.z == tresor_z:
  26.             mc.postToChat("TOUCHE!")
  27.             score = score + 10
  28.             mc.setBlock(tresor_x, tresor_y, tresor_z, block.AIR.id)
  29.             tresor_x = None
  30. PAUSE = 10
  31. chronometre = PAUSE
  32. def annonceLumineuse():
  33.     global chronometre
  34.     if tresor_x != None:
  35.         chronometre = chronometre -1
  36.         if chronometre == 0:
  37.             chronometre = PAUSE
  38.             pos = mc.player.getTilePos()
  39.             diffx = abs(pos.x - tresor_x)
  40.             diffy = abs(pos.y - tresor_y)
  41.             diffz = abs(pos.z - tresor_y)
  42.             diff = diffx + diffy + diffz
  43.             mc.postToChat ("score : " + str(score) + " tresor : " + str(diff))
  44.  
  45. pont = []
  46. def construirePont():
  47.     global score
  48.     pos = mc.player.getTilePos()
  49.     b = mc.getBlock(pos.x, pos.y-1, pos.z)
  50.     if tresor_x == None:
  51.         if len(pont) > 0:
  52.             coordonnee = pont.pop()
  53.             mc.setBlock(coordonnee[0], coordonnee[1], coordonnee[2], block.AIR.id)
  54.             mc.postToChat (" pont: " + str(len(pont)))
  55.             time.sleep (0.25)
  56.     elif b != block.GOLD_BLOCK.id:
  57.         mc.setBlock(pos.x, pos.y-1, pos.z, block.GOLD_BLOCK.id)
  58.         coordonnee = [pos.x, pos.y-1, pos.z]
  59.         pont.append(coordonnee)
  60.         score = score - 1
  61.  
  62. while True:
  63.     if tresor_x == None:
  64.         poserTresor()
  65.  
  66.     construirePont()
  67.     annonceLumineuse()
  68.     verifFrappe()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top