diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityMonster.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityMonster.java | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java index abe59e94..c805fd7a 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -7,27 +7,28 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end -public class EntityMonster extends EntityCreature implements IMonster { +public abstract class EntityMonster extends EntityCreature implements IMonster { protected int damage = 2; public EntityMonster(World world) { super(world); this.health = 20; + this.ax = 5; } - public void v() { - float f = this.c(1.0F); + public void s() { + float f = this.a_(1.0F); if (f > 0.5F) { - this.ay += 2; + this.aO += 2; } - super.v(); + super.s(); } - public void m_() { - super.m_(); + public void s_() { + super.s_(); if (!this.world.isStatic && this.world.spawnMonsters == 0) { this.die(); } @@ -36,11 +37,13 @@ public class EntityMonster extends EntityCreature implements IMonster { protected Entity findTarget() { EntityHuman entityhuman = this.world.findNearbyPlayer(this, 16.0D); - return entityhuman != null && this.e(entityhuman) ? entityhuman : null; + return entityhuman != null && this.f(entityhuman) ? entityhuman : null; } - public boolean damageEntity(Entity entity, int i) { - if (super.damageEntity(entity, i)) { + public boolean damageEntity(DamageSource damagesource, int i) { + if (super.damageEntity(damagesource, i)) { + Entity entity = damagesource.a(); + if (this.passenger != entity && this.vehicle != entity) { if (entity != this) { // CraftBukkit start @@ -68,31 +71,36 @@ public class EntityMonster extends EntityCreature implements IMonster { } } - 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; - // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for lastDamage EntityMonster - // to damage another EntityMonster, and we want to catch those events. - // This does not fire events for slime attacks, av they're not lastDamage EntityMonster. - if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) { - org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); + protected boolean c(Entity entity) { + // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for lastDamage EntityMonster + // to damage another EntityMonster, and we want to catch those events. + // This does not fire events for slime attacks, av they're not lastDamage EntityMonster. + if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) { + org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); - this.world.getServer().getPluginManager().callEvent(event); + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); + this.world.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - entity.damageEntity(this, event.getDamage()); - } - return; + if (!event.isCancelled()) { + return entity.damageEntity(DamageSource.a(this), event.getDamage()); } - // CraftBukkit end - entity.damageEntity(this, this.damage); + return false; + } + // CraftBukkit end + + return entity.damageEntity(DamageSource.a((EntityLiving) this), this.damage); + } + + 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; + this.c(entity); } } protected float a(int i, int j, int k) { - return 0.5F - this.world.n(i, j, k); + return 0.5F - this.world.m(i, j, k); } public void b(NBTTagCompound nbttagcompound) { @@ -113,12 +121,12 @@ public class EntityMonster extends EntityCreature implements IMonster { } else { int l = this.world.getLightLevel(i, j, k); - if (this.world.u()) { - int i1 = this.world.f; + if (this.world.t()) { + int i1 = this.world.k; - this.world.f = 10; + this.world.k = 10; l = this.world.getLightLevel(i, j, k); - this.world.f = i1; + this.world.k = i1; } return l <= this.random.nextInt(8) && super.d(); |