2011-01-29 22:50:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-12 23:55:02 +01:00
|
|
|
import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public abstract class EntityMonster extends EntityCreature implements IMonster {
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
public EntityMonster(World world) {
|
|
|
|
super(world);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.bc = 5;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.bo();
|
2012-07-29 09:33:13 +02:00
|
|
|
float f = this.c(1.0F);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
if (f > 0.5F) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.bA += 2;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
super.c();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void j_() {
|
|
|
|
super.j_();
|
2011-09-24 23:03:31 +02:00
|
|
|
if (!this.world.isStatic && this.world.difficulty == 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
protected Entity findTarget() {
|
2011-11-30 00:17:43 +01:00
|
|
|
EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
return entityhuman != null && this.n(entityhuman) ? entityhuman : null;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isInvulnerable()) {
|
|
|
|
return false;
|
|
|
|
} else if (super.damageEntity(damagesource, i)) {
|
2011-09-15 18:36:27 +02:00
|
|
|
Entity entity = damagesource.getEntity();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.passenger != entity && this.vehicle != entity) {
|
|
|
|
if (entity != this) {
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - we still need to call events for entities without goals
|
2012-03-09 22:40:59 +01:00
|
|
|
if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) {
|
|
|
|
EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
if (event.getTarget() == null) {
|
|
|
|
this.target = null;
|
|
|
|
} else {
|
|
|
|
this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2012-03-09 22:40:59 +01:00
|
|
|
} else {
|
|
|
|
this.target = entity;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean m(Entity entity) {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = this.c(entity);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
|
|
|
if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
|
|
|
|
i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hasEffect(MobEffectList.WEAKNESS)) {
|
|
|
|
i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
i += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity);
|
|
|
|
j += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), i);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
if (j > 0) {
|
|
|
|
entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F));
|
|
|
|
this.motX *= 0.6D;
|
|
|
|
this.motZ *= 0.6D;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
int k = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (k > 0) {
|
|
|
|
entity.setOnFire(k * 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(Entity entity, float f) {
|
|
|
|
if (this.attackTicks <= 0 && f < 2.0F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
|
|
|
|
this.attackTicks = 20;
|
2012-11-06 13:05:28 +01:00
|
|
|
this.m(entity);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 23:10:13 +01:00
|
|
|
public float a(int i, int j, int k) {
|
2012-11-06 13:05:28 +01:00
|
|
|
return 0.5F - this.world.p(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected boolean i_() {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.boundingBox.b);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.b(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = this.world.getLightLevel(i, j, k);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.world.M()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i1 = this.world.j;
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.j = 10;
|
2011-04-20 22:47:26 +02:00
|
|
|
l = this.world.getLightLevel(i, j, k);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.j = i1;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
return l <= this.random.nextInt(8);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public boolean canSpawn() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.i_() && super.canSpawn();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int c(Entity entity) {
|
|
|
|
return 2;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|