2011-01-08 08:40:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
import java.util.Calendar;
|
2013-07-01 13:03:00 +02:00
|
|
|
import java.util.UUID;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-29 02:18:11 +01:00
|
|
|
//CraftBukkit start
|
2013-05-05 16:54:41 +02:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
2013-03-29 02:18:11 +01:00
|
|
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
|
|
import org.bukkit.event.entity.EntityCombustEvent;
|
|
|
|
//CraftBukkit end
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class EntityZombie extends EntityMonster {
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected static final IAttribute bp = (new AttributeRanged("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
|
|
|
|
private static final UUID bq = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
2013-07-09 01:43:37 +02:00
|
|
|
private static final AttributeModifier br = new AttributeModifier(bq, "Baby speed boost", 0.5D, 1);
|
2013-11-04 14:07:38 +01:00
|
|
|
private final PathfinderGoalBreakDoor bs = new PathfinderGoalBreakDoor(this);
|
|
|
|
private int bt;
|
|
|
|
private boolean bu = false;
|
|
|
|
private float bv = -1.0F;
|
|
|
|
private float bw;
|
2013-04-12 01:28:15 +02:00
|
|
|
private int lastTick = MinecraftServer.currentTick; // CraftBukkit
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2011-01-08 08:40:42 +01:00
|
|
|
public EntityZombie(World world) {
|
|
|
|
super(world);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.getNavigation().b(true);
|
2012-03-01 11:49:23 +01:00
|
|
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.0D, false));
|
2013-11-04 14:07:38 +01:00
|
|
|
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityVillager.class, 1.0D, true));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
|
|
|
|
this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false));
|
|
|
|
this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
|
|
|
|
this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
|
|
|
|
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
2013-03-13 23:33:27 +01:00
|
|
|
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true));
|
|
|
|
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 0, false));
|
2013-11-04 14:07:38 +01:00
|
|
|
this.a(0.6F, 1.8F);
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void aD() {
|
|
|
|
super.aD();
|
2013-07-09 01:43:37 +02:00
|
|
|
this.getAttributeInstance(GenericAttributes.b).setValue(40.0D);
|
|
|
|
this.getAttributeInstance(GenericAttributes.d).setValue(0.23000000417232513D);
|
|
|
|
this.getAttributeInstance(GenericAttributes.e).setValue(3.0D);
|
2013-11-04 14:07:38 +01:00
|
|
|
this.bc().b(bp).setValue(this.random.nextDouble() * 0.10000000149011612D);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void c() {
|
|
|
|
super.c();
|
2012-10-25 05:53:23 +02:00
|
|
|
this.getDataWatcher().a(12, Byte.valueOf((byte) 0));
|
|
|
|
this.getDataWatcher().a(13, Byte.valueOf((byte) 0));
|
|
|
|
this.getDataWatcher().a(14, Byte.valueOf((byte) 0));
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public int aV() {
|
|
|
|
int i = super.aV() + 2;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (i > 20) {
|
|
|
|
i = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected boolean bk() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return true;
|
2012-01-12 23:10:13 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean bX() {
|
|
|
|
return this.bu;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(boolean flag) {
|
|
|
|
if (this.bu != flag) {
|
|
|
|
this.bu = flag;
|
|
|
|
if (flag) {
|
|
|
|
this.goalSelector.a(1, this.bs);
|
|
|
|
} else {
|
|
|
|
this.goalSelector.a((PathfinderGoal) this.bs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean isBaby() {
|
|
|
|
return this.getDataWatcher().getByte(12) == 1;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected int getExpValue(EntityHuman entityhuman) {
|
|
|
|
if (this.isBaby()) {
|
|
|
|
this.b = (int) ((float) this.b * 2.5F);
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.getExpValue(entityhuman);
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void setBaby(boolean flag) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.getDataWatcher().watch(12, Byte.valueOf((byte) (flag ? 1 : 0)));
|
|
|
|
if (this.world != null && !this.world.isStatic) {
|
2013-07-09 01:43:37 +02:00
|
|
|
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d);
|
2013-07-01 13:03:00 +02:00
|
|
|
|
|
|
|
attributeinstance.b(br);
|
|
|
|
if (flag) {
|
|
|
|
attributeinstance.a(br);
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
this.k(flag);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isVillager() {
|
|
|
|
return this.getDataWatcher().getByte(13) == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVillager(boolean flag) {
|
|
|
|
this.getDataWatcher().watch(13, Byte.valueOf((byte) (flag ? 1 : 0)));
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void e() {
|
2013-04-27 11:40:05 +02:00
|
|
|
if (this.world.v() && !this.world.isStatic && !this.isBaby()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
float f = this.d(1.0F);
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.i(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))) {
|
2012-10-25 05:53:23 +02:00
|
|
|
boolean flag = true;
|
|
|
|
ItemStack itemstack = this.getEquipment(4);
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (itemstack.g()) {
|
|
|
|
itemstack.setData(itemstack.j() + this.random.nextInt(2));
|
|
|
|
if (itemstack.j() >= itemstack.l()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a(itemstack);
|
|
|
|
this.setEquipment(4, (ItemStack) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
// CraftBukkit start
|
|
|
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.setOnFire(event.getDuration());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
super.e();
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
|
|
|
if (!super.damageEntity(damagesource, f)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
EntityLiving entityliving = this.getGoalTarget();
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (entityliving == null && this.bR() instanceof EntityLiving) {
|
|
|
|
entityliving = (EntityLiving) this.bR();
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entityliving == null && damagesource.getEntity() instanceof EntityLiving) {
|
|
|
|
entityliving = (EntityLiving) damagesource.getEntity();
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (entityliving != null && this.world.difficulty == EnumDifficulty.HARD && (double) this.random.nextFloat() < this.getAttributeInstance(bp).getValue()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.locY);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
EntityZombie entityzombie = new EntityZombie(this.world);
|
|
|
|
|
|
|
|
for (int l = 0; l < 50; ++l) {
|
|
|
|
int i1 = i + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
|
|
|
|
int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
|
|
|
|
int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (World.a((IBlockAccess) this.world, i1, j1 - 1, k1) && this.world.getLightLevel(i1, j1, k1) < 10) {
|
2013-07-01 13:03:00 +02:00
|
|
|
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
|
|
|
|
if (this.world.b(entityzombie.boundingBox) && this.world.getCubes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.world.containsLiquid(entityzombie.boundingBox)) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.world.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
2013-07-01 13:03:00 +02:00
|
|
|
entityzombie.setGoalTarget(entityliving);
|
|
|
|
entityzombie.a((GroupDataEntity) null);
|
2013-07-09 01:43:37 +02:00
|
|
|
this.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
|
|
|
|
entityzombie.getAttributeInstance(bp).a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
|
2013-07-01 13:03:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void h() {
|
|
|
|
if (!this.world.isStatic && this.ca()) {
|
|
|
|
int i = this.cc();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-04-12 01:28:15 +02:00
|
|
|
// CraftBukkit start - Use wall time instead of ticks for villager conversion
|
2013-04-27 11:50:37 +02:00
|
|
|
int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
2013-04-12 01:28:15 +02:00
|
|
|
this.lastTick = MinecraftServer.currentTick;
|
|
|
|
i *= elapsedTicks;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.bt -= i;
|
|
|
|
if (this.bt <= 0) {
|
|
|
|
this.cb();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
super.h();
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean m(Entity entity) {
|
|
|
|
boolean flag = super.m(entity);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag) {
|
|
|
|
int i = this.world.difficulty.a();
|
2013-03-29 02:18:11 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.be() == null && this.isBurning() && this.random.nextFloat() < (float) i * 0.3F) {
|
|
|
|
// CraftBukkit start
|
|
|
|
EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * i);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
entity.setOnFire(event.getDuration());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2013-03-29 02:18:11 +01:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected String t() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.zombie.say";
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected String aT() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.zombie.hurt";
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected String aU() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.zombie.death";
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void a(int i, int j, int k, Block block) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.zombie.step", 0.15F, 1.0F);
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected Item getLoot() {
|
|
|
|
return Items.ROTTEN_FLESH;
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumMonsterType getMonsterType() {
|
|
|
|
return EnumMonsterType.UNDEAD;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Return rare dropped item instead of dropping it
|
2013-11-04 14:07:38 +01:00
|
|
|
protected ItemStack getRareDrop(int i) {
|
2012-10-25 05:53:23 +02:00
|
|
|
switch (this.random.nextInt(3)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
case 0:
|
2013-11-04 14:07:38 +01:00
|
|
|
return new ItemStack(Items.IRON_INGOT, 1, 0);
|
2012-07-29 09:33:13 +02:00
|
|
|
case 1:
|
2013-11-04 14:07:38 +01:00
|
|
|
return new ItemStack(Items.CARROT, 1, 0);
|
2012-07-29 09:33:13 +02:00
|
|
|
case 2:
|
2013-11-04 14:07:38 +01:00
|
|
|
return new ItemStack(Items.POTATO, 1, 0);
|
2012-07-29 09:33:13 +02:00
|
|
|
default:
|
|
|
|
return null;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-21 02:55:45 +01:00
|
|
|
// CraftBukkit end
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void bA() {
|
|
|
|
super.bA();
|
|
|
|
if (this.random.nextFloat() < (this.world.difficulty == EnumDifficulty.HARD ? 0.05F : 0.01F)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = this.random.nextInt(3);
|
|
|
|
|
|
|
|
if (i == 0) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.setEquipment(0, new ItemStack(Items.IRON_SWORD));
|
2012-10-25 05:53:23 +02:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.setEquipment(0, new ItemStack(Items.IRON_SPADE));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
if (this.isBaby()) {
|
|
|
|
nbttagcompound.setBoolean("IsBaby", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isVillager()) {
|
|
|
|
nbttagcompound.setBoolean("IsVillager", true);
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
nbttagcompound.setInt("ConversionTime", this.ca() ? this.bt : -1);
|
|
|
|
nbttagcompound.setBoolean("CanBreakDoors", this.bX());
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
if (nbttagcompound.getBoolean("IsBaby")) {
|
|
|
|
this.setBaby(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbttagcompound.getBoolean("IsVillager")) {
|
|
|
|
this.setVillager(true);
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (nbttagcompound.hasKeyOfType("ConversionTime", 99) && nbttagcompound.getInt("ConversionTime") > -1) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.a(nbttagcompound.getInt("ConversionTime"));
|
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
this.a(nbttagcompound.getBoolean("CanBreakDoors"));
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EntityLiving entityliving) {
|
|
|
|
super.a(entityliving);
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((this.world.difficulty == EnumDifficulty.NORMAL || this.world.difficulty == EnumDifficulty.HARD) && entityliving instanceof EntityVillager) {
|
|
|
|
if (this.random.nextBoolean()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityZombie entityzombie = new EntityZombie(this.world);
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
entityzombie.j(entityliving);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.kill(entityliving);
|
2013-07-01 13:03:00 +02:00
|
|
|
entityzombie.a((GroupDataEntity) null);
|
2012-10-25 05:53:23 +02:00
|
|
|
entityzombie.setVillager(true);
|
|
|
|
if (entityliving.isBaby()) {
|
|
|
|
entityzombie.setBaby(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.world.addEntity(entityzombie);
|
|
|
|
this.world.a((EntityHuman) null, 1016, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public GroupDataEntity a(GroupDataEntity groupdataentity) {
|
2013-07-09 01:43:37 +02:00
|
|
|
Object object = super.a(groupdataentity);
|
2013-07-01 13:03:00 +02:00
|
|
|
float f = this.world.b(this.locX, this.locY, this.locZ);
|
|
|
|
|
|
|
|
this.h(this.random.nextFloat() < 0.55F * f);
|
2013-07-09 01:43:37 +02:00
|
|
|
if (object == null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
object = new GroupDataZombie(this, this.world.random.nextFloat() < 0.05F, this.world.random.nextFloat() < 0.05F, (EmptyClassZombie) null);
|
2013-07-09 01:43:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (object instanceof GroupDataZombie) {
|
|
|
|
GroupDataZombie groupdatazombie = (GroupDataZombie) object;
|
|
|
|
|
|
|
|
if (groupdatazombie.b) {
|
|
|
|
this.setVillager(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groupdatazombie.a) {
|
|
|
|
this.setBaby(true);
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.a(this.random.nextFloat() < f * 0.1F);
|
|
|
|
this.bA();
|
|
|
|
this.bB();
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.getEquipment(4) == null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Calendar calendar = this.world.V();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.PUMPKIN));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.dropChances[4] = 0.0F;
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 13:03:00 +02:00
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
this.getAttributeInstance(GenericAttributes.c).a(new AttributeModifier("Random spawn bonus", this.random.nextDouble() * 0.05000000074505806D, 0));
|
2013-11-04 14:07:38 +01:00
|
|
|
double d0 = this.random.nextDouble() * 1.5D * (double) this.world.b(this.locX, this.locY, this.locZ);
|
|
|
|
|
|
|
|
if (d0 > 1.0D) {
|
|
|
|
this.getAttributeInstance(GenericAttributes.b).a(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (this.random.nextFloat() < f * 0.05F) {
|
2013-07-09 01:43:37 +02:00
|
|
|
this.getAttributeInstance(bp).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 0.25D + 0.5D, 0));
|
|
|
|
this.getAttributeInstance(GenericAttributes.a).a(new AttributeModifier("Leader zombie bonus", this.random.nextDouble() * 3.0D + 1.0D, 2));
|
2013-11-04 14:07:38 +01:00
|
|
|
this.a(true);
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
2013-07-09 01:43:37 +02:00
|
|
|
return (GroupDataEntity) object;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2013-11-04 14:07:38 +01:00
|
|
|
ItemStack itemstack = entityhuman.bD();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack != null && itemstack.getItem() == Items.GOLDEN_APPLE && itemstack.getData() == 0 && this.isVillager() && this.hasEffect(MobEffectList.WEAKNESS)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
this.a(this.random.nextInt(2401) + 3600);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(int i) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.bt = i;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.getDataWatcher().watch(14, Byte.valueOf((byte) 1));
|
2013-11-04 14:07:38 +01:00
|
|
|
this.m(MobEffectList.WEAKNESS.id);
|
|
|
|
this.addEffect(new MobEffect(MobEffectList.INCREASE_DAMAGE.id, i, Math.min(this.world.difficulty.a() - 1, 0)));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.broadcastEntityEffect(this, (byte) 16);
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
protected boolean isTypeNotPersistent() {
|
2013-11-04 14:07:38 +01:00
|
|
|
return !this.ca();
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean ca() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.getDataWatcher().getByte(14) == 1;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void cb() {
|
2012-10-25 05:53:23 +02:00
|
|
|
EntityVillager entityvillager = new EntityVillager(this.world);
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
entityvillager.j(this);
|
|
|
|
entityvillager.a((GroupDataEntity) null);
|
2013-11-04 14:07:38 +01:00
|
|
|
entityvillager.cb();
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.isBaby()) {
|
|
|
|
entityvillager.setAge(-24000);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.world.kill(this);
|
|
|
|
this.world.addEntity(entityvillager);
|
|
|
|
entityvillager.addEffect(new MobEffect(MobEffectList.CONFUSION.id, 200, 0));
|
|
|
|
this.world.a((EntityHuman) null, 1017, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected int cc() {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = 1;
|
|
|
|
|
|
|
|
if (this.random.nextFloat() < 0.01F) {
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
for (int k = (int) this.locX - 4; k < (int) this.locX + 4 && j < 14; ++k) {
|
|
|
|
for (int l = (int) this.locY - 4; l < (int) this.locY + 4 && j < 14; ++l) {
|
|
|
|
for (int i1 = (int) this.locZ - 4; i1 < (int) this.locZ + 4 && j < 14; ++i1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.world.getType(k, l, i1);
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block == Blocks.IRON_FENCE || block == Blocks.BED) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (this.random.nextFloat() < 0.3F) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
public void k(boolean flag) {
|
|
|
|
this.a(flag ? 0.5F : 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected final void a(float f, float f1) {
|
|
|
|
boolean flag = this.bv > 0.0F && this.bw > 0.0F;
|
|
|
|
|
|
|
|
this.bv = f;
|
|
|
|
this.bw = f1;
|
|
|
|
if (!flag) {
|
|
|
|
this.a(1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected final void a(float f) {
|
|
|
|
super.a(this.bv * f, this.bw * f);
|
|
|
|
}
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|