Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #2019-12-08
- #By: Alexis DeSilva
- import pygame
- import nbt
- colorTable = [
- (0,0,0),
- (0,0,0),
- (0,0,0),
- (0,0,0)]
- rawColorTable = [
- (127,178,56),
- (247,233,163),
- (199,199,199),
- (255,0,0),
- (160,160,255),
- (167,167,167),
- (0,124,0),
- (255,255,255),
- (164,168,184),
- (151,109,77),
- (112,112,112),
- (64,64,255),
- (143,119,72),
- (255,252,245),
- (216,127,51),
- (178,76,216),
- (102,153,216),
- (229,229,51),
- (127,204,25),
- (242,127,165),
- (76,76,76),
- (153,153,153),
- (76,127,153),
- (127,63,178),
- (51,76,178),
- (102,76,51),
- (102,127,51),
- (153,51,51),
- (25,25,25),
- (250,238,77),
- (92,219,213),
- (74,128,255),
- (0,217,58),
- (129,86,49),
- (112,2,0),
- (209,177,161),
- (159,82,36),
- (149,87,108),
- (112,108,138),
- (186,133,36),
- (103,117,53),
- (160,77,78),
- (57,41,35),
- (135,107,98),
- (87,92,92),
- (122,73,88),
- (76,62,92),
- (76,50,35),
- (76,82,42),
- (142,60,46),
- (37,22,16)
- ]
- bannerColours = {
- "white":(255,255,255),
- "orange":(216,127,51),
- "magenta":(178,76,216),
- "light_blue":(102,153,216),
- "yellow":(229,229,51),
- "lime":(127,204,25),
- "pink":(242,127,165),
- "gray":(76,76,76),
- "light_gray":(153,153,153),
- "cyan":(76,127,153),
- "purple":(127,63,178),
- "blue":(51,76,178),
- "brown":(102,76,51),
- "green":(102,127,51),
- "red":(153,51,51),
- "black":(25,25,25)
- }
- markerSize = 16
- fontSize = 24
- pygame.font.init()
- font = pygame.font.Font(pygame.font.get_default_font(),fontSize)
- for i in rawColorTable:
- values = [135,180,220,255]
- for v in values:
- colorTable.append((int(i[0]*v/255),int(i[1]*v/255),int(i[2]*v/255)))
- mapArray = [["map_22","map_18",None],["map_12","map_3","map_51"],["map_28",None,None]]
- screen = pygame.display.set_mode((1536,1536))
- xP = 0
- for x in mapArray:
- yP = 0
- for y in x:
- if y != None:
- nbtFile = nbt.nbt.NBTFile(y+".dat",'rb')
- mapScale = 2**nbtFile["data"]["scale"].value
- xPos = 0
- yPos = 0
- for value in nbtFile["data"]["colors"]:
- if xPos >= 128:
- yPos += 1
- xPos = 0
- pygame.draw.rect(screen,colorTable[value],(xPos*4+xP,yPos*4+yP,4,4))
- xPos += 1
- yP += 512
- xP += 512
- xP = 0
- for x in mapArray:
- yP = 0
- for y in x:
- if y != None:
- nbtFile = nbt.nbt.NBTFile(y+".dat",'rb')
- mapScale = 2**nbtFile["data"]["scale"].value
- xPos = 0
- yPos = 0
- for banner in nbtFile["data"]["banners"]:
- trueX = int((banner["Pos"]["X"].value - nbtFile["data"]["xCenter"].value) / mapScale)
- trueZ = int((banner["Pos"]["Z"].value - nbtFile["data"]["zCenter"].value) / mapScale)
- drawX = 256+trueX*4+xP-(markerSize//2)
- drawZ = 256+trueZ*4+yP-(markerSize//2)
- pygame.draw.rect(screen,(0,0,0),(drawX-4,drawZ-4,markerSize+8,markerSize+8))
- pygame.draw.rect(screen,bannerColours[banner["Color"].value],(drawX,drawZ,markerSize,markerSize))
- if len(banner["Name"].value) > 10:
- text = font.render(banner["Name"].value[9:-2],True,(0,0,0),(255,255,255))
- textRect = text.get_rect()
- textRect.center = (drawX,drawZ+markerSize+fontSize)
- screen.blit(text,textRect)
- yP += 512
- xP += 512
- pygame.image.save(screen,"outputMap.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement