Advertisement
slipers

Block move terminal programm

Jun 30th, 2021 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.35 KB | None | 0 0
  1. # CC:Tweaked and Python 3
  2. # Block move terminal programm
  3. # Version 1.0 01.07.2021 00:45:00
  4. # (c) 2021, MCAP-2020 (mcap_nikita & mcap_slipers)
  5.  
  6. import sys
  7. from cc import term, commands
  8.  
  9. cmd = commands
  10. out = term; out.clear(); out.setCursorPos(1,1)
  11.  
  12. # -------------------------------------------------------------
  13.  
  14. tmp_x, tmp_z = None, None
  15. x, y, z = cmd.getBlockPosition()
  16. for dx in -3, 3:
  17.      for dz in -3, 3:
  18.           info = cmd.getBlockInfo(x + dx, y - 1, z + dz)
  19.           if info['name'] == 'minecraft:redstone_block':
  20.                tmp_x = x + dx; tmp_z = z + dz
  21. x = tmp_x; z = tmp_z
  22. if (x == None) or (z == None):
  23.      print("Starting point not found")
  24.      sys.exit()
  25. print("Starting point: %s, %s, %s" % (x, y, z))
  26.  
  27. # -------------------------------------------------------------
  28.  
  29. print("START")
  30. log, move = '', ''
  31. pos_x = x; pos_y = y; pos_z = z
  32. new_x = x; new_y = y; new_z = z
  33. min_x = x - 1; max_x = x + 1; min_y = y; max_y = y + 2; min_z = z - 1; max_z = z + 1
  34. cmd.exec('fill %s %s %s %s %s %s minecraft:air'%(str(min_x), str(min_y), str(min_z), str(max_x), str(max_y), str(max_z)))
  35. cmd.exec('setblock %s %s %s minecraft:concrete'%(str(x), str(y), str(z)))
  36. while True:
  37.      out.setCursorPos(1,3); out.clearLine()
  38.      move = input("Move (f, b, l, r,  u, d), quit (q): ")
  39.      if move == 'q':
  40.           log = log + move
  41.           break
  42.      elif move == 'f':
  43.           new_x = pos_x - 1    
  44.      elif move == 'b':
  45.           new_x = pos_x + 1
  46.      elif move == 'l':
  47.           new_z = pos_z + 1
  48.      elif move == 'r':
  49.           new_z = pos_z - 1
  50.      elif move == 'u':
  51.           new_y = pos_y + 1
  52.      elif move == 'd':
  53.           new_y = pos_y - 1
  54.      if (new_x >= min_x) and (new_x <= max_x) and (new_y >= min_y) and (new_y <= max_y) and (new_z >= min_z) and (new_z <= max_z):
  55.           if (new_x != pos_x) or (new_y != pos_y) or (new_z != pos_z):
  56.                cmd.exec('setblock %s %s %s minecraft:air'%(str(pos_x),str(pos_y),str(pos_z)))
  57.                cmd.exec('setblock %s %s %s minecraft:concrete'%(str(new_x),str(new_y),str(new_z)))
  58.                pos_x = new_x; pos_y = new_y; pos_z = new_z
  59.                log = log + move + "-"
  60.           else:
  61.                new_x = pos_x; new_y = pos_y; new_z = pos_z
  62.      else:
  63.           new_x = pos_x; new_y = pos_y; new_z = pos_z
  64. print("LOG: " + log)
  65. print("END")
  66. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement