minecraft.js
Version:
Minecraft data serialization/deserialization and networking
34 lines (29 loc) • 1.37 kB
JavaScript
(function(Minecraft) {
/** @constructor */
Minecraft.MobEntity = function(args) {
if(typeof args != 'object') args = {};
Minecraft.Entity.call(this, args);
this.attackTime = args.attackTime || 0;
this.deathTime = args.deathTime || 0;
this.health = args.health || this.getMaxHealth();
};
Minecraft.MobEntity.prototype = new Minecraft.Entity();
Minecraft.MobEntity.prototype.constructor = Minecraft.MobEntity;
Minecraft.MobEntity.prototype.tagFormat = Minecraft.Entity.prototype.tagFormat.clone().append([
new Minecraft.TagFormat('short', 'AttackTime', 'attackTime'),
new Minecraft.TagFormat('short', 'DeathTime', 'deathTime'),
new Minecraft.TagFormat('short', 'Health', 'health'),
new Minecraft.TagFormat('short', 'HurtTime', 'hurtTime')
]);
Minecraft.MobEntity.prototype.getMaxHealth = function() {
if(Minecraft.MobEntity.prototype.livestock.indexOf(this.id) == -1) {
return 20;
} else {
return 10;
}
};
Minecraft.MobEntity.prototype.livestock = ["Pig", "Sheep", "Cow", "Chicken"];
Minecraft.MobEntity.prototype.mobs = ["Mob", "Monster", "Creeper", "Skeleton",
"Spider", "Giant", "Zombie", "Slime", "PigZombie", "Ghast", "Wolf",
"Squid", "Enderman", "Silverfish", "CaveSpider"];
})(Minecraft);