# Golf Your Favorite Minecraft Tool

In Minecraft, the default item textures are all reasonably simple 16×16 pixel images, which makes them seem ideal for golfing.

Below are simplified textures of the five "core" diamond tools in Minecraft: pickaxe, shovel, axe, sword, and hoe.

The images shown are enlarged to show their detail. Click on an image to view its correctly sized 16×16 pixel version.

To make golfing easier, I've modified each of them from the originals to only use the five same 24-bit RGB colors:

• R=75 G=82 B=73 for the background.
• R=51 G=235 B=203 for the diamond tool heads.
• R=14 G=63 B=54 for the diamond outlines.
• R=137 G=103 B=39 for the wooden handle core.
• R=40 G=30 B=11 for the wooden handle outlines.

Choose your favorite tool out of the five and write a program that outputs its simplified 16×16 pixel texture in any common lossless truecolor image format (such as bpm, png, ppm, etc.).

So, for example, if you chose the axe, you would write a program that outputs this image:

No input should be taken and a web connection should not be required. The image can be output as a file with the name of your choice, or the raw image file data can be output to stdout, or you can simply display the image.

You only need to choose one of the five images. The program that outputs any one of the five images in the fewest number of bytes is the winner.

You may write programs for more than one of the images, but only the one with the minimum number of bytes counts towards your score. If there's a tie, the highest voted post wins.

If you enjoy PPCG and play Minecraft, I invite you to come join our trial Minecraft server. Just ask in the dedicated chatroom.

• "Enlarged to show detail." I can only think of cereal boxes. Jun 11 '15 at 4:17
• I think there may be some compression issues or you have some typos in the colours. Mathematica claims, these five colours are used (at least for the shovel): [[76 82 73] [26 63 54] [106 234 204] [39 30 13] [133 102 45]] Jun 11 '15 at 12:21
• Jun 11 '15 at 16:48
• @MartinBüttner Are you sure? I re-downloaded the shovel image and made sure that the 5 colors are correct. I also made sure there were exactly 5 colors. imgur may be compressing the enlarged images but those are not the ones you should be using. Jun 11 '15 at 18:37
• @Calvin'sHobbies Is input allowed? Oct 6 '15 at 17:46

# Minecraft 18w11a (.mcfunction), 757 bytes

fill ~ ~ ~ ~15 ~ ~15 ice
fill ~13 ~ ~13 ~7 ~ ~11 cyan_wool
fill ~12 ~ ~14 ~10 ~ ~8 cyan_wool
fill ~12 ~ ~13 ~10 ~ ~11 diamond_block
fill ~11 ~ ~12 ~9 ~ ~10 diamond_block
fill ~10 ~ ~11 ~8 ~ ~9 diamond_block
fill ~3 ~ ~4 ~1 ~ ~2 dirt
setblock ~3 ~ ~4 oak_planks
setblock ~2 ~ ~3 oak_planks
clone ~3 ~ ~4 ~1 ~ ~2 ~4 ~ ~5
setblock ~4 ~ ~5 oak_planks
setblock ~4 ~ ~7 ice
setblock ~6 ~ ~5 ice
clone ~6 ~ ~5 ~4 ~ ~7 ~7 ~ ~8
setblock ~9 ~ ~10 diamond_block
setblock ~4 ~ ~4 dirt
setblock ~3 ~ ~5 dirt
setblock ~7 ~ ~7 dirt
setblock ~6 ~ ~8 dirt
setblock ~1 ~ ~2 ice
fill ~12 ~ ~9 ~12 ~ ~8 ice
setblock ~11 ~ ~8 ice
fill ~8 ~ ~13 ~7 ~ ~13 ice
setblock ~7 ~ ~12 ice
fill ~ ~ ~ ~15 ~ ~15 light_gray_concrete replace ice
fill ~ ~ ~ ~9 ~ ~10 dark_oak_bark replace dirt


Of course someone had to answer the question with Minecraft. Place answer inside of a datapack, and run with /function <packname>:<filename>. The shovel is drawn relative to you in the +X and +Z direction. Colors are wrong but I'll count that as a language limitation ;)

But the shovel is actually made out of wood and diamonds!!!!

## Output

• oh hey, that's cool!
– quat
Mar 19 '18 at 14:51
• You can use TNT or air instead of dirt to save 6 bytes. Mar 25 '21 at 22:52
• You can save a lot of bytes by using absolute coordinates. Mar 26 '21 at 13:28
• @Makonede air can use keep shorter?
– l4m2
May 5 '21 at 19:53

document.write(<p style="width:1px;height:1px;box-shadow:${'931a31b31841940a40b40c41951a51b50c50d51e53f52b61c60d60e62f63c73d70e70f71b83c82d83e81a93b92c939a3aa2ba38b39b2ab37c38c29c36d37d28d35e36e27e34f35f26f34g35g3'.replace(/.../g,e=>(p=parseInt)(e[0],17)+px${p(e[1],17)}px 0 #${['33EBCB','0E3F36','896727','281E0B'][e[2]]},)}9px 9px 0 8px #4B5249")  This heavily abuses CSS3 box-shadows to create a pixelized version of the image, in this case the Minecraft hoe. The Stack Snippet below uses ES5 for easy testing and is somewhat ungolfed (You'll have to zoom in to see it well). s='931a31b31841940a40b40c41951a51b50c50d51e53f52b61c60d60e62f63c73d70e70f71b83c82d83e81a93b92c939a3aa2ba38b39b2ab37c38c29c36d37d28d35e36e27e34f35f26f34g35g3'.replace(/.../g,function(e){ return parseInt(e[0],17)+'px '+parseInt(e[1],17)+'px 0 #'+['33EBCB','0E3F36','896727','281E0B'][e[2]]+',' }) document.write('<p style="width:1px;height:1px;box-shadow:'+s+'9px 9px 0 8px #4B5249"') • Could this be shortened by using base64 encoding instead of hex? Jun 11 '15 at 3:34 • The largest source image is 297 bytes. Kinda sad to be over that :) – J B Jun 11 '15 at 7:40 • @JB It's [kolmogorov-complexity] for a reason ;) Jun 11 '15 at 16:45 • @ThomasKwa Doesn't base64 actually make it longer? (It's actually base-17 because there's gs near the end.) Jun 11 '15 at 16:46 • I don't know how expensive interpreting base64 encoding is in Javascript, but the string literal itself should be 2/3rds the size in base64 as in hex. Jun 11 '15 at 16:51 # CJam, 119 bytes 'P3NGSGN255N]o67T"…vîþáy$<OW¥ÓNZ"256b9b~99T]2/e~W%"LRI?6jêÌ'
…f-":i3/f=F,_W%:)+{)/(\:~}%{G/({)S*S+oNo}%1>\:~+}G*


Try it online!

I've chosen the shovel.

This program prints a PPM file to STDOUT.

The basic idea is to unroll the image along antidiagonals and then use run-length encoding. With this technique, the shovel contains the fewest runs. For reference the number of runs per image (in the order given in the challenge) is:

{60, 26, 38, 43, 37}

• This is 129 bytes, not 119. May 27 '21 at 20:12
• @Makonede I don't think so? May 28 '21 at 10:10
• Well, TIO also claims Pyth uses an SBCS when in reality it does not. If CJam really does use an SBCS, could you link to it? May 28 '21 at 16:00
• CJam doesn't so much use an SBCS as allow any byte value in the program @Makonede. These are often shown in older CJam answers, such as this, using extended ASCII characters to avoid using unprintable characters. May 28 '21 at 17:15

# 05AB1E, 113 97 bytes

-16 by using RLE (run-length encoding) for the color palette indices.

„P3žvD₅•P{¡æjž²+JGÀ‰íÔñ•Ƶ‡в3ô•N…ý~îc|\мï¶„Ä^€¿^•5в¦•RθÅª<≠cλS²bÖ"₁Þ@„ÉI¬5øëY4ÀΘØ¥P@û h•29вÅΓè˜»»


Try it online! Beats all other answers. Outputs a plain PPM of a diamond hoe.

Note: The first » can be a ) (or a ¶, ð, or õ) to output the image data separated by spaces: Try it online! However, in the official PPM Format Specification, under Plain PPM, it states:

• No line should be longer than 70 characters.

It still renders properly, but is not recommended.

The first » can also be a  with no change in functionality: Try it online!

### Pure GIF compression, 109 107 bytes

•+Ùι1Ù³œ¤∞4ûи„ĆQ´ηÏzεÝ₅¼úΣ¨ü6Ó…Ï,È–ð:<û∞¢Þ§α»«¥<çp:Ù“ζÞ¢ó‡lÿнδßiÌ\$}ªiƒ*₅xΛxJ=yh‹×м’’®']!JÍ¦Z¹JQc›Vàÿ¸Ìм•h2ô


Try it online! Outputs as a list of hexadecimal codepoints.

•...•h2ô  # trimmed program
•...•     # 121686424391392225557581524495943776461362082974476220323034665137613008241067075561955081975776948192923502794622971144661356950543760600319115998403445050769039958830830234731371315671091547736084642764295720991029129326629299863698388004372539...
ô  # split into pieces of length...
2   # literal
# implicit output


# Node.JS using jimp, 393377 376 bytes

377, 376 thanks to Makonede

new(require('jimp'))(16,16,1263684095,(e,i)=>{i.z=i.setPixelColor;i.z(x=673057791,2,12);i.z(x,4,14);i.z(d=871091199,13,3);for(j=0;j<8;j++){i.z(w=2305239039,3+j,13-j);i.z(x,2+j,13-j);i.z(x,3+j,14-j)}for(j=0;j<3;j++){i.z(e=239023871,11+j,2);i.z(e,14,3+j);i.z(e,8+j,5-j);i.z(d,9+j,5-j);i.z(d,10+j,5-j);i.z(d,10+j,6-j);i.z(d,11+j,6-j);i.z(d,11+j,7-j);i.z(e,11+j,8-j)}i.write('')})


I'm not sure if this one is allowed as it uses a separate library for processing the image.

Uses hex colors in decimal, sets i.s to i.setPixelColor to save bytes, sets color variables as it's first used

• as long as the question does not disallow libraries, and the library is explicitly stated, it is fine. Mar 28 '21 at 14:12
• However, it is a good idea to tell us which tool you've made. Mar 28 '21 at 14:12
• -49 by removing some semicolons, using an empty file name, using s instead of i.s, and only assigning variables when first needed: new(require('jimp'))(16,16,1263684095,(e,i)=>{(s=i.setPixelColor)(x=673057791,2,12);s(x,4,14);s(d=871091199,13,3);for(j=0;j<8;j++){s(w=2305239039,3+j,13-j);s(x,2+j,13-j);s(x,3+j,14-j)}for(j=0;j<3;j++){s(e=239023871,11+j,2);s(e,14,3+j);s(e,8+j,5-j);s(d,9+j,5-j);s(d,10+j,5-j);s(d,10+j,6-j);s(d,11+j,6-j);s(d,11+j,7-j);s(e,11+j,8-j)}i.write('')}). Mar 29 '21 at 22:15
• @Makonede that's actually really clever assigning variables like that. however i tried using s instead of i.s and jimp threw an error for this being undefined.
– mekb
Mar 30 '21 at 6:27
• actually it seems it's if it's s not i.s or if it's using the assignment in the use or both
– mekb
Mar 30 '21 at 6:54

## Python 3, 483 bytes

I chose to make the sword

from PIL import Image as IG, ImageColor as IC
s=IG.new('RGB',(16,16))
w='#6b6727'
b='#4b5249'
d='#33ebcb'
a='#0e3f36'
n='#281e0b'
t=b*13+a*3+b*12+a+d*2+a+b*11+a+d*3+a+b*10+a+d*3+a+b+b*9+a+d*3+a+b*2+b*8+a+d*3+a+b*3+b*2+a*2+b*3+a+d*3+a+b*4+b*2+a+d+a+b+a+d*3+a+b*5+b*3+a+d+a+d*3+a+b*6+b*3+a+d+a+d*2+a+b*7+b*4+a+d+a*2+b*8+b*3+n+w+a+d*2+a+b*7+b*2+n+w+n+b+a*2+d+a+b*6+a*2+w+n+b*4+a*2+b*6+a+d+a+b*13+a*3+b*13
s.putdata([IC.getrgb(t[i:i+7]) for i in range(0,len(t),7)])
s.save('s.png','PNG')


here is the output:

I created a string for each color, and combined them to get a string of hexadecimal numbers. Then I used the python image library to convert that string into an image.

• You can save 5 bytes by replacing 's.png' with ''. It assumes that the system the program is being run on allows empty file names. This does not apply to any popular OS (AFAIK) but it's OK to make assumptions here. Mar 25 '21 at 21:11
• Actually, you can save 7 bytes by using s.save('.png'). The format argument isn't necessary if a corresponding extension is given, and s.save('.png') is 2 bytes shorter than s.save('','PNG'). Mar 26 '21 at 17:07
• You can save another 9 on top of that by changing Image as IG, ImageColor as IC to Image,ImageColor as c, changing IG to Image, changing IC to c, removing the space between (t[i:i+7]) and for, and replacing len(t) with 1792 (the guaranteed length of t). Mar 26 '21 at 17:15
• And yet another 18 saved by 1. fixing some inefficiencies in the definition of t (for example, b+b*9 -> b*10), 2. making t a tuple instead of a string, 3. not using a variable (this method uses t only once) and 4. using all that to allow for a much shorter putdata method: s.putdata(map(c.getrgb,[*[b]*13,a,a,a,*[b]*12,a,d,d,a,*[b]*11,a,d,d,d,a,*[*[b]*10,a,d,d,d,a]*2,*[b]*5,a,a,b,b,b,a,d,d,d,a,*[b]*6,a,d,a,b,a,d,d,d,a,*[b]*8,a,d,a,d,d,d,a,*[b]*9,a,d,a,d,d,a,*[b]*11,a,d,a,a,*[b]*11,n,w,a,d,d,a,*[b]*9,n,w,n,b,a,a,d,a,*[b]*6,a,a,w,n,*[b]*4,a,a,*[b]*6,a,d,a,*[b]*13,a,a,a,*[b]*13])). Mar 26 '21 at 17:30
• (continued from previous comment because of length limitations) A total of 34 bytes saved! Mar 26 '21 at 17:30

# GIF, 102 bytes

Hexdump:

00000000: 4749 4638 3961 1000 1000 7000 002c 0000  GIF89a....p..,..
00000010: 0000 1000 1000 824b 5249 0e3f 3633 ebcb  .......KRI.?63..
00000020: 281e 0b89 6727 0000 0000 0000 0000 0003  (...g'..........
00000030: 3308 babc f12d 8220 4490 8cd6 8b67 b59d  3....-. D....g..
00000040: b785 1a98 71a2 9981 25da 506d 078f a4e5  ....q...%.Pm....
00000050: 4a03 a1dd 4c3e 4cb0 c883 f073 f082 21c5  J...L>L....s..!.
00000060: 8327 4900 003b                           .'I..;


Renders as:

Since this is a minecraft problem, I will do a command block solution: 50 characters

summon ItemFrame ~1 ~0 ~0 {Item:{id:diamond_axe}}


creates an item frame showing an axe.

• You need to output an image. Sep 8 '15 at 1:23
• The image is outputted on screen as part of the game. Sep 12 '15 at 4:24
• Because of perspective, it will never be a perfect image - it's supposed to be pixelart too, only 16x16. Sep 12 '15 at 5:11
• I think this qualifies as a standard loophole - same as getting the image from an external source. I think it would have been alright to summon blocks to act as the pixels, with the colors as close as possible. Sep 22 '15 at 22:06
• I'm not sure if this is valid because if I change the texture back for my game and run this command from a command block. it will not display the correct image. Also -2 bytes by getting rid of the 0s in ~0; ~ behaves identically to ~0. Mar 19 '18 at 12:10