From 403a2acc53fa893bd364654ba4c3b48a942b0b98 Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Thu, 10 Feb 2011 01:20:50 +0100 Subject: [PATCH] Added default player-faces. --- web/minecraft.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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