2012-03-05 23:23:13 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-05 23:32:09 +01:00
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
|
|
|
|
|
2012-03-05 23:23:13 +01:00
|
|
|
public class EntityIronGolem extends EntityGolem {
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private int e = 0;
|
|
|
|
Village d = null;
|
|
|
|
private int f;
|
2012-03-05 23:23:13 +01:00
|
|
|
private int g;
|
|
|
|
|
|
|
|
public EntityIronGolem(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/villager_golem.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(1.4F, 2.9F);
|
|
|
|
this.getNavigation().a(true);
|
2012-03-05 23:23:13 +01:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 0.25F, true));
|
|
|
|
this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.22F, 32.0F));
|
|
|
|
this.goalSelector.a(3, new PathfinderGoalMoveThroughVillage(this, 0.16F, true));
|
|
|
|
this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 0.16F));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalOfferFlower(this));
|
|
|
|
this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.16F));
|
|
|
|
this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
|
|
|
|
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
|
|
|
this.targetSelector.a(1, new PathfinderGoalDefendVillage(this));
|
|
|
|
this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, false, true, IMonster.a));
|
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(16, Byte.valueOf((byte) 0));
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean bh() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected void bp() {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (--this.e <= 0) {
|
|
|
|
this.e = 70 + this.random.nextInt(50);
|
|
|
|
this.d = this.world.villages.getClosestVillage(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 32);
|
|
|
|
if (this.d == null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.aO();
|
2012-03-05 23:23:13 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = this.d.getCenter();
|
2012-03-05 23:23:13 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.b(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, (int) ((float) this.d.getSize() * 0.6F));
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
super.bp();
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxHealth() {
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected int h(int i) {
|
2012-03-05 23:23:13 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
protected void o(Entity entity) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (entity instanceof IMonster && this.aE().nextInt(20) == 0) {
|
2013-01-17 10:28:44 +01:00
|
|
|
this.setGoalTarget((EntityLiving) entity);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
super.o(entity);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
|
|
|
super.c();
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.f > 0) {
|
|
|
|
--this.f;
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.g > 0) {
|
|
|
|
--this.g;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.motX * this.motX + this.motZ * this.motZ > 2.500000277905201E-7D && this.random.nextInt(5) == 0) {
|
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
int l = this.world.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
if (l > 0) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.world.addParticle("tilecrack_" + l + "_" + this.world.getData(i, j, k), this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.random.nextFloat() - 0.5D), 0.5D, ((double) this.random.nextFloat() - 0.5D) * 4.0D);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(Class oclass) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.p() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setBoolean("PlayerCreated", this.p());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
this.setPlayerCreated(nbttagcompound.getBoolean("PlayerCreated"));
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean m(Entity entity) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.f = 10;
|
2012-03-05 23:23:13 +01:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 4);
|
|
|
|
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), 7 + this.random.nextInt(15));
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
entity.motY += 0.4000000059604645D;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.irongolem.throw", 1.0F, 1.0F);
|
2012-03-05 23:23:13 +01:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public Village m() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.d;
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(boolean flag) {
|
2012-03-05 23:23:13 +01:00
|
|
|
this.g = flag ? 400 : 0;
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 11);
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bb() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bc() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return "mob.irongolem.hit";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
protected String bd() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return "mob.irongolem.death";
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(int i, int j, int k, int l) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.irongolem.walk", 1.0F, 1.0F);
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2012-03-05 23:32:09 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2012-03-05 23:23:13 +01:00
|
|
|
int j = this.random.nextInt(3);
|
|
|
|
|
|
|
|
int k;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (j > 0) {
|
2012-12-17 08:31:41 +01:00
|
|
|
loot.add(CraftItemStack.asNewCraftStack(Item.byId[Block.RED_ROSE.id], j));
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
k = 3 + this.random.nextInt(3);
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (k > 0) {
|
2012-12-17 08:31:41 +01:00
|
|
|
loot.add(CraftItemStack.asNewCraftStack(Item.IRON_INGOT, k));
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
2012-03-05 23:32:09 +01:00
|
|
|
|
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
|
|
|
|
// CraftBukkit end
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int o() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return this.g;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean p() {
|
2012-03-05 23:23:13 +01:00
|
|
|
return (this.datawatcher.getByte(16) & 1) != 0;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void setPlayerCreated(boolean flag) {
|
2012-03-05 23:23:13 +01:00
|
|
|
byte b0 = this.datawatcher.getByte(16);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1)));
|
|
|
|
} else {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2)));
|
|
|
|
}
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public void die(DamageSource damagesource) {
|
|
|
|
if (!this.p() && this.killer != null && this.d != null) {
|
|
|
|
this.d.a(this.killer.getName(), -5);
|
|
|
|
}
|
|
|
|
|
|
|
|
super.die(damagesource);
|
|
|
|
}
|
2012-03-05 23:23:13 +01:00
|
|
|
}
|