diff --git a/web/minecraft.js b/web/minecraft.js index 1c193539..976e3dc3 100644 --- a/web/minecraft.js +++ b/web/minecraft.js @@ -16,7 +16,7 @@ function blitImage(ctx, image, sx ,sy, sw, sh, dx, dy, dw, dh) { } } -function createMinecraftHead(player,completed) { +function createMinecraftHead(player,completed,failed) { var skinImage = new Image(); skinImage.onload = function() { var headCanvas = document.createElement('canvas'); @@ -27,6 +27,13 @@ function createMinecraftHead(player,completed) { blitImage(headContext, skinImage, 40,8,8,8, 0,0,8,8); completed(headCanvas); }; + skinImage.onerror = function() { + if (skinImage.src == 'http://www.minecraft.net/img/char.png') { + failed(); + } else { + skinImage.src = 'http://www.minecraft.net/img/char.png'; + } + }; skinImage.src = 'http://www.minecraft.net/skin/' + player + '.png'; } @@ -60,6 +67,8 @@ function getMinecraftHead(player,size,completed) { for(i=0;i