2012-03-05 23:23:13 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class EntityOcelot extends EntityTameableAnimal {
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
private PathfinderGoalTempt bq;
|
2012-03-05 23:23:13 +01:00
|
|
|
|
|
|
|
public EntityOcelot(World world) {
|
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.6F, 0.8F);
|
|
|
|
this.getNavigation().a(true);
|
2012-03-05 23:23:13 +01:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalFloat(this));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.goalSelector.a(2, this.bp);
|
|
|
|
this.goalSelector.a(3, this.bq = new PathfinderGoalTempt(this, 0.6D, Item.RAW_FISH.id, true));
|
|
|
|
this.goalSelector.a(4, new PathfinderGoalAvoidPlayer(this, EntityHuman.class, 16.0F, 0.8D, 1.33D));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 5.0F));
|
|
|
|
this.goalSelector.a(6, new PathfinderGoalJumpOnBlock(this, 1.33D));
|
2012-03-22 21:39:39 +01:00
|
|
|
this.goalSelector.a(7, new PathfinderGoalLeapAtTarget(this, 0.3F));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.goalSelector.a(8, new PathfinderGoalOcelotAttack(this));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.goalSelector.a(9, new PathfinderGoalBreed(this, 0.8D));
|
|
|
|
this.goalSelector.a(10, new PathfinderGoalRandomStroll(this, 0.8D));
|
2012-03-22 21:39:39 +01:00
|
|
|
this.goalSelector.a(11, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 10.0F));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.targetSelector.a(1, new PathfinderGoalRandomTargetNonTamed(this, EntityChicken.class, 750, false));
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
2012-03-05 23:23:13 +01:00
|
|
|
this.datawatcher.a(18, Byte.valueOf((byte) 0));
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public void bj() {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.getControllerMove().a()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
double d0 = this.getControllerMove().b();
|
2012-03-05 23:23:13 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (d0 == 0.6D) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.setSneaking(true);
|
2012-03-05 23:23:13 +01:00
|
|
|
this.setSprinting(false);
|
2013-07-01 13:03:00 +02:00
|
|
|
} else if (d0 == 1.33D) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.setSneaking(false);
|
2012-03-05 23:23:13 +01:00
|
|
|
this.setSprinting(true);
|
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.setSneaking(false);
|
2012-03-05 23:23:13 +01:00
|
|
|
this.setSprinting(false);
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
} else {
|
|
|
|
this.setSneaking(false);
|
|
|
|
this.setSprinting(false);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 10:28:44 +01:00
|
|
|
protected boolean isTypeNotPersistent() {
|
2013-07-01 13:03:00 +02:00
|
|
|
return !this.isTamed() && this.ticksLived > 2400;
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
public boolean be() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected void ay() {
|
|
|
|
super.ay();
|
|
|
|
this.getAttributeInstance(GenericAttributes.a).setValue(10.0D);
|
|
|
|
this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected void b(float f) {}
|
2012-03-05 23:23:13 +01:00
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setInt("CatType", this.getCatType());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
this.setCatType(nbttagcompound.getInt("CatType"));
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected String r() {
|
2013-07-09 01:43:37 +02:00
|
|
|
return this.isTamed() ? (this.bY() ? "mob.cat.purr" : (this.random.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : "";
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected String aN() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return "mob.cat.hitt";
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected String aO() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return "mob.cat.hitt";
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
protected float aZ() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return 0.4F;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getLootId() {
|
2012-04-15 16:16:43 +02:00
|
|
|
return Item.LEATHER.id;
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean m(Entity entity) {
|
2013-07-01 13:03:00 +02:00
|
|
|
return entity.damageEntity(DamageSource.mobAttack(this), 3.0F);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isInvulnerable()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bp.setSitting(false);
|
|
|
|
return super.damageEntity(damagesource, f);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:32:09 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2012-04-15 16:16:43 +02:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit - Call EntityDeathEvent
|
2012-03-05 23:32:09 +01:00
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2012-03-05 23:23:13 +01:00
|
|
|
ItemStack itemstack = entityhuman.inventory.getItemInHand();
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.isTamed()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (entityhuman.getName().equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) {
|
|
|
|
this.bp.setSitting(!this.isSitting());
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2013-07-01 13:03:00 +02:00
|
|
|
} else if (this.bq.f() && itemstack != null && itemstack.id == Item.RAW_FISH.id && entityhuman.e(this) < 9.0D) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
// CraftBukkit - added event call and isCancelled check
|
|
|
|
if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
|
|
|
this.setTamed(true);
|
|
|
|
this.setCatType(1 + this.world.random.nextInt(3));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.setOwnerName(entityhuman.getName());
|
2013-07-09 01:43:37 +02:00
|
|
|
this.i(true);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.bp.setSitting(true);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 7);
|
|
|
|
} else {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.i(false);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 6);
|
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
return true;
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
return super.a(entityhuman);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public EntityOcelot b(EntityAgeable entityageable) {
|
2012-03-05 23:23:13 +01:00
|
|
|
EntityOcelot entityocelot = new EntityOcelot(this.world);
|
|
|
|
|
|
|
|
if (this.isTamed()) {
|
|
|
|
entityocelot.setOwnerName(this.getOwnerName());
|
|
|
|
entityocelot.setTamed(true);
|
|
|
|
entityocelot.setCatType(this.getCatType());
|
|
|
|
}
|
|
|
|
|
|
|
|
return entityocelot;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean c(ItemStack itemstack) {
|
2012-03-05 23:23:13 +01:00
|
|
|
return itemstack != null && itemstack.id == Item.RAW_FISH.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean mate(EntityAnimal entityanimal) {
|
|
|
|
if (entityanimal == this) {
|
|
|
|
return false;
|
|
|
|
} else if (!this.isTamed()) {
|
|
|
|
return false;
|
|
|
|
} else if (!(entityanimal instanceof EntityOcelot)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
EntityOcelot entityocelot = (EntityOcelot) entityanimal;
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
return !entityocelot.isTamed() ? false : this.bY() && entityocelot.bY();
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getCatType() {
|
|
|
|
return this.datawatcher.getByte(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCatType(int i) {
|
|
|
|
this.datawatcher.watch(18, Byte.valueOf((byte) i));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canSpawn() {
|
|
|
|
if (this.world.random.nextInt(3) == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) {
|
2012-03-05 23:23:13 +01:00
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.boundingBox.b);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
|
|
|
|
if (j < 63) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int l = this.world.getTypeId(i, j - 1, k);
|
|
|
|
|
|
|
|
if (l == Block.GRASS.id || l == Block.LEAVES.id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getLocalizedName() {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.hasCustomName() ? this.getCustomName() : (this.isTamed() ? "entity.Cat.name" : super.getLocalizedName());
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public GroupDataEntity a(GroupDataEntity groupdataentity) {
|
|
|
|
groupdataentity = super.a(groupdataentity);
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.world.random.nextInt(7) == 0) {
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
EntityOcelot entityocelot = new EntityOcelot(this.world);
|
|
|
|
|
|
|
|
entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
|
|
|
|
entityocelot.setAge(-24000);
|
|
|
|
this.world.addEntity(entityocelot);
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 13:03:00 +02:00
|
|
|
|
|
|
|
return groupdataentity;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
public EntityAgeable createChild(EntityAgeable entityageable) {
|
|
|
|
return this.b(entityageable);
|
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|