Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- # Define the expanded block palette
- BLOCK_PALETTE = {
- (255, 0, 0): "red_concrete",
- (0, 255, 0): "lime_concrete",
- (0, 0, 255): "blue_concrete",
- (255, 255, 0): "yellow_concrete",
- (255, 105, 180): "pink_concrete",
- (255, 165, 0): "orange_concrete",
- (128, 0, 128): "purple_concrete",
- (0, 255, 255): "cyan_concrete",
- (255, 0, 255): "magenta_concrete",
- (128, 128, 128): "gray_concrete",
- (192, 192, 192): "light_gray_concrete",
- (105, 105, 105): "dark_gray_concrete",
- (139, 69, 19): "brown_concrete",
- (0, 0, 0): "black_concrete",
- (255, 228, 225): "white_concrete",
- (255, 228, 196): "light_gray_concrete",
- (220, 20, 60): "red_terracotta",
- (255, 160, 122): "sandstone",
- (184, 134, 11): "gold_block",
- (112, 128, 144): "stone_slab"
- }
- def map_color_to_block(color):
- return BLOCK_PALETTE.get(color, "stone") # Default to stone if color not found
- def generate_minecraft_commands(image_path, output_file):
- with Image.open(image_path) as img:
- img = img.resize((128, 128)) # Resize to 128x128 if needed
- pixels = img.load()
- with open(output_file, 'w') as file:
- for y in range(128):
- for x in range(128):
- color = pixels[x, y]
- block = map_color_to_block(color)
- command = f"/fill {x} 0 {y} {x} 255 {y} {block}\n"
- file.write(command)
- if __name__ == "__main__":
- generate_minecraft_commands("path/to/your/image.png", "commands.txt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement