2012-03-01 11:49:23 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public abstract class EntityAgeable extends EntityCreature {
|
|
|
|
public boolean ageLocked = false; // CraftBukkit
|
|
|
|
|
|
|
|
public EntityAgeable(World world) {
|
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public abstract EntityAgeable createChild(EntityAgeable entityageable);
|
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
|
|
|
ItemStack itemstack = entityhuman.inventory.getItemInHand();
|
|
|
|
|
|
|
|
if (itemstack != null && itemstack.id == Item.MONSTER_EGG.id && !this.world.isStatic) {
|
|
|
|
Class oclass = EntityTypes.a(itemstack.getData());
|
|
|
|
|
|
|
|
if (oclass != null && oclass.isAssignableFrom(this.getClass())) {
|
|
|
|
EntityAgeable entityageable = this.createChild(this);
|
|
|
|
|
|
|
|
if (entityageable != null) {
|
|
|
|
entityageable.setAge(-24000);
|
|
|
|
entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
|
2012-11-20 21:01:36 +01:00
|
|
|
this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
|
2012-11-20 15:27:47 +01:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
2012-12-20 05:03:52 +01:00
|
|
|
--itemstack.count;
|
|
|
|
if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinit"
|
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
2012-11-23 04:42:34 +01:00
|
|
|
}
|
2012-11-20 15:27:47 +01:00
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.a(entityhuman);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
2012-03-01 11:49:23 +01:00
|
|
|
this.datawatcher.a(12, new Integer(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAge() {
|
|
|
|
return this.datawatcher.getInt(12);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAge(int i) {
|
|
|
|
this.datawatcher.watch(12, Integer.valueOf(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setInt("Age", this.getAge());
|
|
|
|
nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
this.setAge(nbttagcompound.getInt("Age"));
|
|
|
|
this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
|
|
|
super.c();
|
2012-03-01 11:49:23 +01:00
|
|
|
int i = this.getAge();
|
|
|
|
|
|
|
|
if (ageLocked) return; // CraftBukkit
|
|
|
|
if (i < 0) {
|
|
|
|
++i;
|
|
|
|
this.setAge(i);
|
|
|
|
} else if (i > 0) {
|
|
|
|
--i;
|
|
|
|
this.setAge(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isBaby() {
|
|
|
|
return this.getAge() < 0;
|
|
|
|
}
|
|
|
|
}
|