dynmap/web/js/minecraft.js

34 lines
947 B
JavaScript
Raw Normal View History

function createMinecraftHead(player,size,completed,failed) {
var faceImage = new Image();
faceImage.onload = function() {
completed(faceImage);
};
faceImage.onerror = function() {
failed();
2011-02-10 01:20:50 +01:00
};
faceImage.src = dynmap.options.tileUrl + 'faces/' + size + 'x' + size + '/' + player + '.png';
}
function getMinecraftHead(player,size,completed) {
createMinecraftHead(player, size, completed, function() {
console.error('Failed to retrieve face of "', player, '" with size "', size, '"!')
});
}
2011-02-13 23:30:19 +01:00
function getMinecraftTime(servertime) {
servertime = parseInt(servertime);
var day = servertime >= 0 && servertime < 13700;
return {
servertime: servertime,
days: parseInt((servertime+8000) / 24000),
// Assuming it is day at 8:00
hours: (parseInt(servertime / 1000)+8) % 24,
minutes: parseInt(((servertime / 1000) % 1) * 60),
seconds: parseInt(((((servertime / 1000) % 1) * 60) % 1) * 60),
day: day,
night: !day
};
}