1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
   | from mcpi import minecraft, block from colorsys import rgb_to_hsv from PIL import Image import numpy
  colors = dict((     ((255, 255, 255), "0"),      ((249, 255, 254), "0"),       ((249, 128, 29), "1"),       ((199, 78, 189), "2"),       ((58, 179, 218), "3"),       ((254, 216, 61), "4"),       ((128, 199, 31), "5"),       ((243, 139, 170), "6"),       ((71, 79, 82), "7"),       ((157, 157, 151), "8"),       ((22, 156, 156), "9"),       ((137, 50, 184), "10"),       ((60, 68, 170), "11"),       ((131, 84, 50), "12"),       ((94, 124, 22), "13"),       ((176, 46, 38), "14"),       ((29, 29, 33), "15"),       ((0, 0, 0), "15"),  
  ))
 
  def to_hsv(color):     return rgb_to_hsv(*[x / 255.0 for x in color])
 
  def color_dist(c1, c2):     return sum((a - b) ** 2 for a, b in zip(to_hsv(c1), to_hsv(c2)))
 
  def min_color_diff(color_to_match, colors):     return min((color_dist(color_to_match, test), colors[test]) for test in colors)
 
 
  def get_player_direction(rotation):     rec = [-90, 0, 90, 180]       if abs(rotation) < 45:         return '+z'     elif abs(rotation) > 145:         return '-z'     elif rotation < 0:         return '+x'     else:         return '-x'
 
  mc = minecraft.Minecraft.create() im = Image.open('6.jpg') im = im.convert('RGB') list = numpy.array(im) size = list.shape start = mc.player.getTilePos() for i in range(size[0]):     for j in range(size[1]):         item = min_color_diff(list[i][j], colors)         mc.setBlock(start.x + size[0] - i, start.y, start.z + j, 251, int(item[1]))
   |