2012-04-28 19:11:47 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-04-28 19:26:07 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
|
2012-04-28 19:11:47 +02:00
|
|
|
public class EntitySilverfish extends EntityMonster {
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private int d;
|
2012-04-28 19:11:47 +02:00
|
|
|
|
|
|
|
public EntitySilverfish(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/silverfish.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.3F, 0.7F);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.bI = 0.6F;
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxHealth() {
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected boolean f_() {
|
2012-04-28 19:11:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Entity findTarget() {
|
|
|
|
double d0 = 8.0D;
|
|
|
|
|
|
|
|
return this.world.findNearbyVulnerablePlayer(this, d0);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bb() {
|
2012-04-28 19:11:47 +02:00
|
|
|
return "mob.silverfish.say";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bc() {
|
2012-04-28 19:11:47 +02:00
|
|
|
return "mob.silverfish.hit";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bd() {
|
2012-04-28 19:11:47 +02:00
|
|
|
return "mob.silverfish.kill";
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.isInvulnerable()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (this.d <= 0 && (damagesource instanceof EntityDamageSource || damagesource == DamageSource.MAGIC)) {
|
|
|
|
this.d = 20;
|
|
|
|
}
|
2012-04-28 19:11:47 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
return super.damageEntity(damagesource, i);
|
|
|
|
}
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(Entity entity, float f) {
|
|
|
|
if (this.attackTicks <= 0 && f < 1.2F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
|
|
|
|
this.attackTicks = 20;
|
2012-12-20 05:03:52 +01:00
|
|
|
this.m(entity);
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(int i, int j, int k, int l) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.silverfish.step", 0.15F, 1.0F);
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected int getLootId() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void l_() {
|
|
|
|
this.ay = this.yaw;
|
|
|
|
super.l_();
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bq() {
|
|
|
|
super.bq();
|
2012-04-28 19:11:47 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int k;
|
|
|
|
int l;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.d > 0) {
|
|
|
|
--this.d;
|
|
|
|
if (this.d == 0) {
|
2012-04-28 19:11:47 +02:00
|
|
|
i = MathHelper.floor(this.locX);
|
|
|
|
j = MathHelper.floor(this.locY);
|
|
|
|
k = MathHelper.floor(this.locZ);
|
|
|
|
boolean flag = false;
|
|
|
|
|
|
|
|
for (l = 0; !flag && l <= 5 && l >= -5; l = l <= 0 ? 1 - l : 0 - l) {
|
|
|
|
for (int i1 = 0; !flag && i1 <= 10 && i1 >= -10; i1 = i1 <= 0 ? 1 - i1 : 0 - i1) {
|
|
|
|
for (int j1 = 0; !flag && j1 <= 10 && j1 >= -10; j1 = j1 <= 0 ? 1 - j1 : 0 - j1) {
|
|
|
|
int k1 = this.world.getTypeId(i + i1, j + l, k + j1);
|
|
|
|
|
|
|
|
if (k1 == Block.MONSTER_EGGS.id) {
|
2012-04-28 19:26:07 +02:00
|
|
|
// CraftBukkit start
|
2012-11-30 18:53:31 +01:00
|
|
|
if (CraftEventFactory.callEntityChangeBlockEvent(this, i + i1, j + l, k + j1, 0, 0).isCancelled()) {
|
2012-04-28 19:26:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.world.setAir(i + i1, j + l, k + j1, false);
|
2012-04-28 19:11:47 +02:00
|
|
|
Block.MONSTER_EGGS.postBreak(this.world, i + i1, j + l, k + j1, 0);
|
|
|
|
if (this.random.nextBoolean()) {
|
|
|
|
flag = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.target == null && !this.k()) {
|
2012-04-28 19:11:47 +02:00
|
|
|
i = MathHelper.floor(this.locX);
|
|
|
|
j = MathHelper.floor(this.locY + 0.5D);
|
|
|
|
k = MathHelper.floor(this.locZ);
|
|
|
|
int l1 = this.random.nextInt(6);
|
|
|
|
|
|
|
|
l = this.world.getTypeId(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]);
|
2013-03-13 23:33:27 +01:00
|
|
|
if (BlockMonsterEggs.d(l)) {
|
2012-04-28 19:26:07 +02:00
|
|
|
// CraftBukkit start
|
2013-03-13 23:33:27 +01:00
|
|
|
if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.e(l)).isCancelled()) {
|
2012-04-28 19:26:07 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.world.setTypeIdAndData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.e(l), 3);
|
|
|
|
this.aU();
|
2012-04-28 19:11:47 +02:00
|
|
|
this.die();
|
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i();
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.target != null && !this.k()) {
|
2012-04-28 19:11:47 +02:00
|
|
|
this.target = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float a(int i, int j, int k) {
|
|
|
|
return this.world.getTypeId(i, j - 1, k) == Block.STONE.id ? 10.0F : super.a(i, j, k);
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected boolean i_() {
|
2012-04-28 19:11:47 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canSpawn() {
|
|
|
|
if (super.canSpawn()) {
|
|
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, 5.0D);
|
|
|
|
|
|
|
|
return entityhuman == null;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int c(Entity entity) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumMonsterType getMonsterType() {
|
|
|
|
return EnumMonsterType.ARTHROPOD;
|
2012-04-28 19:11:47 +02:00
|
|
|
}
|
|
|
|
}
|