Lichtenstein meets 3D pixel art in Minecraft

I built a pixelated, embossed version of Lichtenstein’s piece in Minecraft Classic. 

Rather than building it manually, block by block, I wrote bunch of scripts (Mac and Windows versions included below). Photoshop or equivalent is also required to convert images to custom indexed palettes.

This is a fun, little project to that will help you practice your basic PHP coding skills, indexed-colour standard (used in e. g. GIF images), AppleScript and pixel-art of course.

Dimensions

I used a 128x128x64 blocks private map on Aeries server.

I hung the picture in the sky, on top of the ‘map’ facing down, to be able to use the maximum size available of 128×128 blocks. It might not seem much of a resolution, but it is still nearly 16.5k blocks!

How?

First, I created a special, custom colour palette in Photoshop, based on blocks of Minecraft. It contains 28 colours plus 1 for alpha channel.

Then I resized the source image and converted it to indexed-colour using this custom palette.

I completely replaced the polka-dots/raster pattern as in original it was too fine and wouldn’t be visible in the low resolution.

Then I wrote a PHP script that converts the indexed bitmap to polar coordinates: x, y, z. Colour attribute is specified as block name. The PHP script generates a file with a list of simple commands to tell Minecraft where to place a blocks and which material e. g. /place obsidian 0 0 0

After that I decided to create another bitmap for depth, just to add it a bit of a 3D touch. 

And finally used an AppleScript to automate sending nearly 50.000 lines via Java Applet loader and watching it building the image in Minecraft. So cool!

The code

To run the below code just drop in you’re web server htdocs or public-html directory. You can use a local server such as MAMP/WAMP or equivalent.

The script will generate a yet another script that you’ll run on Minecraft server. (:

<?php

// Mac version 1.2, copy and paste result to AppleScript editor.
// 


include ('header.html');
?>
delay 5<br />
tell application "System Events"<br /><br />
<?php


$base_x = 0; 
$base_y = 0;
$base_z = 0;
// left top corner of the image, change if you want your built to appear in the different part of the map



$colour = array( "0" => "", "1" => "cobblestone", "2" => "dirt", "3" => "wood", "4" => "mossy_cobblestone", "5" => "sand", "6" => "gravel", "7" => "red", "8" => "orange", "9" => "yellow", "10" => "greenyellow", "11" => "green", "12" => "springgreen", "13" => "cyan", "14" => "blue", "15" => "blueviolet", "16" => "indigo", "17" => "purple", "18" => "magenta", "19" => "pink", "20" => "black", "21" => "gray", "22" => "white", "23" => "coal", "24" => "iron_ore", "25" => "gold_ore", "26" => "obsidian", "27" => "alpha" );
// assigns the colour indexes from the image to Minecraft block names



$image = imagecreatefrompng("bitmap.png"); // indexed colour bitmap- 29 colours including alpha, use the Photoshop colour swatch provided 
$emboss_map = imagecreatefrompng("emboss-map.png"); // indexed colour bitmap - for flat images use solid black, more colour indexes in the bitmap, more depth levels in your built 
$image_size = getimagesize("bitmap.png");
// $counter = 1;



for ($z = 0; $z <= $image_size[1]-1; $z++) {
	for ($x = 0; $x <= $image_size[0]-1; $x++) {
		if ( $colour[imagecolorat( $image , $x , $z )] != "alpha" ) {
		
			$output_x = $base_x + $x;
			$output_z = $base_z + $z;
			$output_y = $base_y + ( imagecolorat( $emboss_map , $x , $z )); // change to (-) for negative embossing
			$block = $colour[imagecolorat ( $image , $x , $z )];
			
			echo 'keystroke "t/place ' . $block . ' ' . $output_x . ' ' . $output_y . ' ' . $output_z . '"<br />keystroke return<br />delay 0.1<br />';	
		}
	}
	
	
// $counter++;
// 	if ( $counter > 3 ) { // extra delay, helpful with large images
// 		echo 'delay 1<br />';
// 		$counter = 1;
//	}	

}



?>
<br />end tell
<?php
include ('footer.html');
?>

Download

Here are the source files: Image-to-Mincraft.zip.

The folder contains 2 example images bitmap.png and emboss-map.png. You can just go ahead and replace those images with yours. Don’t go to crazy about their size! Most Minecraft servers support only up to few hundreds of pixels either way.

Windows users might also need to download a program that automatically sends ‘fake’ keyboard input such as PF Autotyper. On Mac this is done directly with AppleScript.


Update Spring 2020

Classic has been discontinued, but a browser-based remake came out in  2019. Source: Wikipedia

You may also like…