EntityZombie .java

net.minecraft.entity.monster.EntityZombie (class, 822 lines): members: babySpeedBoostModifier, getConversionTimeBoost, isBreakDoorsTaskSet, conversionTime.

net.minecraft.entity.monsterclass822 linescommonextends EntityMob28.0 KB

API Surface (41)

void applyEntityAI()
void applyEntityAttributes()
void entityInit()
int getTotalArmorValue()
boolean isBreakDoorsTaskSet()
void setBreakDoorsAItask(boolean par1)
boolean isChild()
int getExperiencePoints(EntityPlayer player)
void setChild(boolean childZombie)
boolean isVillager()
void setVillager(boolean villager)
void onLivingUpdate()
boolean attackEntityFrom(DamageSource source, float amount)
void onUpdate()
boolean attackEntityAsMob(Entity entityIn)
String getLivingSound()
String getHurtSound()
String getDeathSound()
void playStepSound(BlockPos pos, Block blockIn)
Item getDropItem()
EnumCreatureAttribute getCreatureAttribute()
void addRandomDrop()
void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
void writeEntityToNBT(NBTTagCompound tagCompound)
void readEntityFromNBT(NBTTagCompound tagCompund)
void onKillEntity(EntityLivingBase entityLivingIn)
float getEyeHeight()
boolean func_175448_a(ItemStack stack)
IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
boolean interact(EntityPlayer player)
void startConversion(int ticks)
void handleStatusUpdate(byte id)
boolean canDespawn()
boolean isConverting()
void convertToVillager()
int getConversionTimeBoost()
void setChildSize(boolean isChild)
void setSize(float width, float height)
void multiplySize(float size)
double getYOffset()
void onDeath(DamageSource cause)

Fields & Constants (8)

reinforcementChance
babySpeedBoostUUID
babySpeedBoostModifier
breakDoor
conversionTime
isBreakDoorsTaskSet
zombieWidth
zombieHeight

String literals (17)

"zombie.spawnReinforcements"
"Spawn Reinforcements Chance"
"Baby speed boost"
"Zombie reinforcement caller charge"
"Zombie reinforcement callee charge"
"mob.zombie.say"
"mob.zombie.hurt"
"mob.zombie.death"
"mob.zombie.step"
"IsBaby"
"IsVillager"
"ConversionTime"
"CanBreakDoors"
"Random spawn bonus"
"Random zombie-spawn bonus"
"Leader zombie bonus"
"mob.zombie.remedy"

Full Source

EntityZombie.java822 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.monster;
2
3
import java.util.Calendar;
4
import java.util.List;
5
import java.util.UUID;
6
import net.minecraft.block.Block;
7
import net.minecraft.entity.Entity;
8
import net.minecraft.entity.EntityLiving;
9
import net.minecraft.entity.EntityLivingBase;
10
import net.minecraft.entity.EnumCreatureAttribute;
11
import net.minecraft.entity.IEntityLivingData;
12
import net.minecraft.entity.SharedMonsterAttributes;
13
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
14
import net.minecraft.entity.ai.EntityAIBreakDoor;
15
import net.minecraft.entity.ai.EntityAIHurtByTarget;
16
import net.minecraft.entity.ai.EntityAILookIdle;
17
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
18
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
19
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
20
import net.minecraft.entity.ai.EntityAISwimming;
21
import net.minecraft.entity.ai.EntityAIWander;
22
import net.minecraft.entity.ai.EntityAIWatchClosest;
23
import net.minecraft.entity.ai.attributes.AttributeModifier;
24
import net.minecraft.entity.ai.attributes.IAttribute;
25
import net.minecraft.entity.ai.attributes.IAttributeInstance;
26
import net.minecraft.entity.ai.attributes.RangedAttribute;
27
import net.minecraft.entity.passive.EntityChicken;
28
import net.minecraft.entity.passive.EntityVillager;
29
import net.minecraft.entity.player.EntityPlayer;
30
import net.minecraft.init.Blocks;
31
import net.minecraft.init.Items;
32
import net.minecraft.item.Item;
33
import net.minecraft.item.ItemStack;
34
import net.minecraft.nbt.NBTTagCompound;
35
import net.minecraft.pathfinding.PathNavigateGround;
36
import net.minecraft.potion.Potion;
37
import net.minecraft.potion.PotionEffect;
38
import net.minecraft.util.BlockPos;
39
import net.minecraft.util.DamageSource;
40
import net.minecraft.util.EntitySelectors;
41
import net.minecraft.util.MathHelper;
42
import net.minecraft.world.DifficultyInstance;
43
import net.minecraft.world.EnumDifficulty;
44
import net.minecraft.world.World;
45
46
public class EntityZombie extends EntityMob
47
{
48
    /**
49
     * The attribute which determines the chance that this mob will spawn reinforcements
50
     */
51
    protected static final IAttribute reinforcementChance = (new RangedAttribute((IAttribute)null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).setDescription("Spawn Reinforcements Chance");
52
    private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
53
    private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1);
54
    private final EntityAIBreakDoor breakDoor = new EntityAIBreakDoor(this);
55
56
    /**
57
     * Ticker used to determine the time remaining for this zombie to convert into a villager when cured.
58
     */
59
    private int conversionTime;
60
    private boolean isBreakDoorsTaskSet = false;
61
62
    /** The width of the entity */
63
    private float zombieWidth = -1.0F;
64
65
    /** The height of the the entity. */
66
    private float zombieHeight;
67
68
    public EntityZombie(World worldIn)
69
    {
70
        super(worldIn);
71
        ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
72
        this.tasks.addTask(0, new EntityAISwimming(this));
73
        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
74
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
75
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
76
        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
77
        this.tasks.addTask(8, new EntityAILookIdle(this));
78
        this.applyEntityAI();
79
        this.setSize(0.6F, 1.95F);
80
    }
81
82
    protected void applyEntityAI()
83
    {
84
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
85
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityIronGolem.class, 1.0D, true));
86
        this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
87
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityPigZombie.class}));
88
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
89
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
90
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));
91
    }
92
93
    protected void applyEntityAttributes()
94
    {
95
        super.applyEntityAttributes();
96
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D);
97
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
98
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
99
        this.getAttributeMap().registerAttribute(reinforcementChance).setBaseValue(this.rand.nextDouble() * 0.10000000149011612D);
100
    }
101
102
    protected void entityInit()
103
    {
104
        super.entityInit();
105
        this.getDataWatcher().addObject(12, Byte.valueOf((byte)0));
106
        this.getDataWatcher().addObject(13, Byte.valueOf((byte)0));
107
        this.getDataWatcher().addObject(14, Byte.valueOf((byte)0));
108
    }
109
110
    /**
111
     * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
112
     */
113
    public int getTotalArmorValue()
114
    {
115
        int i = super.getTotalArmorValue() + 2;
116
117
        if (i > 20)
118
        {
119
            i = 20;
120
        }
121
122
        return i;
123
    }
124
125
    public boolean isBreakDoorsTaskSet()
126
    {
127
        return this.isBreakDoorsTaskSet;
128
    }
129
130
    /**
131
     * Sets or removes EntityAIBreakDoor task
132
     */
133
    public void setBreakDoorsAItask(boolean par1)
134
    {
135
        if (this.isBreakDoorsTaskSet != par1)
136
        {
137
            this.isBreakDoorsTaskSet = par1;
138
139
            if (par1)
140
            {
141
                this.tasks.addTask(1, this.breakDoor);
142
            }
143
            else
144
            {
145
                this.tasks.removeTask(this.breakDoor);
146
            }
147
        }
148
    }
149
150
    /**
151
     * If Animal, checks if the age timer is negative
152
     */
153
    public boolean isChild()
154
    {
155
        return this.getDataWatcher().getWatchableObjectByte(12) == 1;
156
    }
157
158
    /**
159
     * Get the experience points the entity currently has.
160
     */
161
    protected int getExperiencePoints(EntityPlayer player)
162
    {
163
        if (this.isChild())
164
        {
165
            this.experienceValue = (int)((float)this.experienceValue * 2.5F);
166
        }
167
168
        return super.getExperiencePoints(player);
169
    }
170
171
    /**
172
     * Set whether this zombie is a child.
173
     */
174
    public void setChild(boolean childZombie)
175
    {
176
        this.getDataWatcher().updateObject(12, Byte.valueOf((byte)(childZombie ? 1 : 0)));
177
178
        if (this.worldObj != null && !this.worldObj.isRemote)
179
        {
180
            IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
181
            iattributeinstance.removeModifier(babySpeedBoostModifier);
182
183
            if (childZombie)
184
            {
185
                iattributeinstance.applyModifier(babySpeedBoostModifier);
186
            }
187
        }
188
189
        this.setChildSize(childZombie);
190
    }
191
192
    /**
193
     * Return whether this zombie is a villager.
194
     */
195
    public boolean isVillager()
196
    {
197
        return this.getDataWatcher().getWatchableObjectByte(13) == 1;
198
    }
199
200
    /**
201
     * Set whether this zombie is a villager.
202
     */
203
    public void setVillager(boolean villager)
204
    {
205
        this.getDataWatcher().updateObject(13, Byte.valueOf((byte)(villager ? 1 : 0)));
206
    }
207
208
    /**
209
     * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
210
     * use this to react to sunlight and start to burn.
211
     */
212
    public void onLivingUpdate()
213
    {
214
        if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild())
215
        {
216
            float f = this.getBrightness(1.0F);
217
            BlockPos blockpos = new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
218
219
            if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
220
            {
221
                boolean flag = true;
222
                ItemStack itemstack = this.getEquipmentInSlot(4);
223
224
                if (itemstack != null)
225
                {
226
                    if (itemstack.isItemStackDamageable())
227
                    {
228
                        itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
229
230
                        if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
231
                        {
232
                            this.renderBrokenItemStack(itemstack);
233
                            this.setCurrentItemOrArmor(4, (ItemStack)null);
234
                        }
235
                    }
236
237
                    flag = false;
238
                }
239
240
                if (flag)
241
                {
242
                    this.setFire(8);
243
                }
244
            }
245
        }
246
247
        if (this.isRiding() && this.getAttackTarget() != null && this.ridingEntity instanceof EntityChicken)
248
        {
249
            ((EntityLiving)this.ridingEntity).getNavigator().setPath(this.getNavigator().getPath(), 1.5D);
250
        }
251
252
        super.onLivingUpdate();
253
    }
254
255
    /**
256
     * Called when the entity is attacked.
257
     */
258
    public boolean attackEntityFrom(DamageSource source, float amount)
259
    {
260
        if (super.attackEntityFrom(source, amount))
261
        {
262
            EntityLivingBase entitylivingbase = this.getAttackTarget();
263
264
            if (entitylivingbase == null && source.getEntity() instanceof EntityLivingBase)
265
            {
266
                entitylivingbase = (EntityLivingBase)source.getEntity();
267
            }
268
269
            if (entitylivingbase != null && this.worldObj.getDifficulty() == EnumDifficulty.HARD && (double)this.rand.nextFloat() < this.getEntityAttribute(reinforcementChance).getAttributeValue())
270
            {
271
                int i = MathHelper.floor_double(this.posX);
272
                int j = MathHelper.floor_double(this.posY);
273
                int k = MathHelper.floor_double(this.posZ);
274
                EntityZombie entityzombie = new EntityZombie(this.worldObj);
275
276
                for (int l = 0; l < 50; ++l)
277
                {
278
                    int i1 = i + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
279
                    int j1 = j + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
280
                    int k1 = k + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
281
282
                    if (World.doesBlockHaveSolidTopSurface(this.worldObj, new BlockPos(i1, j1 - 1, k1)) && this.worldObj.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10)
283
                    {
284
                        entityzombie.setPosition((double)i1, (double)j1, (double)k1);
285
286
                        if (!this.worldObj.isAnyPlayerWithinRangeAt((double)i1, (double)j1, (double)k1, 7.0D) && this.worldObj.checkNoEntityCollision(entityzombie.getEntityBoundingBox(), entityzombie) && this.worldObj.getCollidingBoundingBoxes(entityzombie, entityzombie.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.getEntityBoundingBox()))
287
                        {
288
                            this.worldObj.spawnEntityInWorld(entityzombie);
289
                            entityzombie.setAttackTarget(entitylivingbase);
290
                            entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
291
                            this.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
292
                            entityzombie.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
293
                            break;
294
                        }
295
                    }
296
                }
297
            }
298
299
            return true;
300
        }
301
        else
302
        {
303
            return false;
304
        }
305
    }
306
307
    /**
308
     * Called to update the entity's position/logic.
309
     */
310
    public void onUpdate()
311
    {
312
        if (!this.worldObj.isRemote && this.isConverting())
313
        {
314
            int i = this.getConversionTimeBoost();
315
            this.conversionTime -= i;
316
317
            if (this.conversionTime <= 0)
318
            {
319
                this.convertToVillager();
320
            }
321
        }
322
323
        super.onUpdate();
324
    }
325
326
    public boolean attackEntityAsMob(Entity entityIn)
327
    {
328
        boolean flag = super.attackEntityAsMob(entityIn);
329
330
        if (flag)
331
        {
332
            int i = this.worldObj.getDifficulty().getDifficultyId();
333
334
            if (this.getHeldItem() == null && this.isBurning() && this.rand.nextFloat() < (float)i * 0.3F)
335
            {
336
                entityIn.setFire(2 * i);
337
            }
338
        }
339
340
        return flag;
341
    }
342
343
    /**
344
     * Returns the sound this mob makes while it's alive.
345
     */
346
    protected String getLivingSound()
347
    {
348
        return "mob.zombie.say";
349
    }
350
351
    /**
352
     * Returns the sound this mob makes when it is hurt.
353
     */
354
    protected String getHurtSound()
355
    {
356
        return "mob.zombie.hurt";
357
    }
358
359
    /**
360
     * Returns the sound this mob makes on death.
361
     */
362
    protected String getDeathSound()
363
    {
364
        return "mob.zombie.death";
365
    }
366
367
    protected void playStepSound(BlockPos pos, Block blockIn)
368
    {
369
        this.playSound("mob.zombie.step", 0.15F, 1.0F);
370
    }
371
372
    protected Item getDropItem()
373
    {
374
        return Items.rotten_flesh;
375
    }
376
377
    /**
378
     * Get this Entity's EnumCreatureAttribute
379
     */
380
    public EnumCreatureAttribute getCreatureAttribute()
381
    {
382
        return EnumCreatureAttribute.UNDEAD;
383
    }
384
385
    /**
386
     * Causes this Entity to drop a random item.
387
     */
388
    protected void addRandomDrop()
389
    {
390
        switch (this.rand.nextInt(3))
391
        {
392
            case 0:
393
                this.dropItem(Items.iron_ingot, 1);
394
                break;
395
396
            case 1:
397
                this.dropItem(Items.carrot, 1);
398
                break;
399
400
            case 2:
401
                this.dropItem(Items.potato, 1);
402
        }
403
    }
404
405
    /**
406
     * Gives armor or weapon for entity based on given DifficultyInstance
407
     */
408
    protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
409
    {
410
        super.setEquipmentBasedOnDifficulty(difficulty);
411
412
        if (this.rand.nextFloat() < (this.worldObj.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F))
413
        {
414
            int i = this.rand.nextInt(3);
415
416
            if (i == 0)
417
            {
418
                this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
419
            }
420
            else
421
            {
422
                this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_shovel));
423
            }
424
        }
425
    }
426
427
    /**
428
     * (abstract) Protected helper method to write subclass entity data to NBT.
429
     */
430
    public void writeEntityToNBT(NBTTagCompound tagCompound)
431
    {
432
        super.writeEntityToNBT(tagCompound);
433
434
        if (this.isChild())
435
        {
436
            tagCompound.setBoolean("IsBaby", true);
437
        }
438
439
        if (this.isVillager())
440
        {
441
            tagCompound.setBoolean("IsVillager", true);
442
        }
443
444
        tagCompound.setInteger("ConversionTime", this.isConverting() ? this.conversionTime : -1);
445
        tagCompound.setBoolean("CanBreakDoors", this.isBreakDoorsTaskSet());
446
    }
447
448
    /**
449
     * (abstract) Protected helper method to read subclass entity data from NBT.
450
     */
451
    public void readEntityFromNBT(NBTTagCompound tagCompund)
452
    {
453
        super.readEntityFromNBT(tagCompund);
454
455
        if (tagCompund.getBoolean("IsBaby"))
456
        {
457
            this.setChild(true);
458
        }
459
460
        if (tagCompund.getBoolean("IsVillager"))
461
        {
462
            this.setVillager(true);
463
        }
464
465
        if (tagCompund.hasKey("ConversionTime", 99) && tagCompund.getInteger("ConversionTime") > -1)
466
        {
467
            this.startConversion(tagCompund.getInteger("ConversionTime"));
468
        }
469
470
        this.setBreakDoorsAItask(tagCompund.getBoolean("CanBreakDoors"));
471
    }
472
473
    /**
474
     * This method gets called when the entity kills another one.
475
     */
476
    public void onKillEntity(EntityLivingBase entityLivingIn)
477
    {
478
        super.onKillEntity(entityLivingIn);
479
480
        if ((this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
481
        {
482
            if (this.worldObj.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
483
            {
484
                return;
485
            }
486
487
            EntityLiving entityliving = (EntityLiving)entityLivingIn;
488
            EntityZombie entityzombie = new EntityZombie(this.worldObj);
489
            entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
490
            this.worldObj.removeEntity(entityLivingIn);
491
            entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
492
            entityzombie.setVillager(true);
493
494
            if (entityLivingIn.isChild())
495
            {
496
                entityzombie.setChild(true);
497
            }
498
499
            entityzombie.setNoAI(entityliving.isAIDisabled());
500
501
            if (entityliving.hasCustomName())
502
            {
503
                entityzombie.setCustomNameTag(entityliving.getCustomNameTag());
504
                entityzombie.setAlwaysRenderNameTag(entityliving.getAlwaysRenderNameTag());
505
            }
506
507
            this.worldObj.spawnEntityInWorld(entityzombie);
508
            this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
509
        }
510
    }
511
512
    public float getEyeHeight()
513
    {
514
        float f = 1.74F;
515
516
        if (this.isChild())
517
        {
518
            f = (float)((double)f - 0.81D);
519
        }
520
521
        return f;
522
    }
523
524
    protected boolean func_175448_a(ItemStack stack)
525
    {
526
        return stack.getItem() == Items.egg && this.isChild() && this.isRiding() ? false : super.func_175448_a(stack);
527
    }
528
529
    /**
530
     * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
531
     * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
532
     */
533
    public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata)
534
    {
535
        livingdata = super.onInitialSpawn(difficulty, livingdata);
536
        float f = difficulty.getClampedAdditionalDifficulty();
537
        this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
538
539
        if (livingdata == null)
540
        {
541
            livingdata = new EntityZombie.GroupData(this.worldObj.rand.nextFloat() < 0.05F, this.worldObj.rand.nextFloat() < 0.05F);
542
        }
543
544
        if (livingdata instanceof EntityZombie.GroupData)
545
        {
546
            EntityZombie.GroupData entityzombie$groupdata = (EntityZombie.GroupData)livingdata;
547
548
            if (entityzombie$groupdata.isVillager)
549
            {
550
                this.setVillager(true);
551
            }
552
553
            if (entityzombie$groupdata.isChild)
554
            {
555
                this.setChild(true);
556
557
                if ((double)this.worldObj.rand.nextFloat() < 0.05D)
558
                {
559
                    List<EntityChicken> list = this.worldObj.<EntityChicken>getEntitiesWithinAABB(EntityChicken.class, this.getEntityBoundingBox().expand(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
560
561
                    if (!list.isEmpty())
562
                    {
563
                        EntityChicken entitychicken = (EntityChicken)list.get(0);
564
                        entitychicken.setChickenJockey(true);
565
                        this.mountEntity(entitychicken);
566
                    }
567
                }
568
                else if ((double)this.worldObj.rand.nextFloat() < 0.05D)
569
                {
570
                    EntityChicken entitychicken1 = new EntityChicken(this.worldObj);
571
                    entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
572
                    entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData)null);
573
                    entitychicken1.setChickenJockey(true);
574
                    this.worldObj.spawnEntityInWorld(entitychicken1);
575
                    this.mountEntity(entitychicken1);
576
                }
577
            }
578
        }
579
580
        this.setBreakDoorsAItask(this.rand.nextFloat() < f * 0.1F);
581
        this.setEquipmentBasedOnDifficulty(difficulty);
582
        this.setEnchantmentBasedOnDifficulty(difficulty);
583
584
        if (this.getEquipmentInSlot(4) == null)
585
        {
586
            Calendar calendar = this.worldObj.getCurrentDate();
587
588
            if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
589
            {
590
                this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin));
591
                this.equipmentDropChances[4] = 0.0F;
592
            }
593
        }
594
595
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
596
        double d0 = this.rand.nextDouble() * 1.5D * (double)f;
597
598
        if (d0 > 1.0D)
599
        {
600
            this.getEntityAttribute(SharedMonsterAttributes.followRange).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
601
        }
602
603
        if (this.rand.nextFloat() < f * 0.05F)
604
        {
605
            this.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
606
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
607
            this.setBreakDoorsAItask(true);
608
        }
609
610
        return livingdata;
611
    }
612
613
    /**
614
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
615
     */
616
    public boolean interact(EntityPlayer player)
617
    {
618
        ItemStack itemstack = player.getCurrentEquippedItem();
619
620
        if (itemstack != null && itemstack.getItem() == Items.golden_apple && itemstack.getMetadata() == 0 && this.isVillager() && this.isPotionActive(Potion.weakness))
621
        {
622
            if (!player.capabilities.isCreativeMode)
623
            {
624
                --itemstack.stackSize;
625
            }
626
627
            if (itemstack.stackSize <= 0)
628
            {
629
                player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
630
            }
631
632
            if (!this.worldObj.isRemote)
633
            {
634
                this.startConversion(this.rand.nextInt(2401) + 3600);
635
            }
636
637
            return true;
638
        }
639
        else
640
        {
641
            return false;
642
        }
643
    }
644
645
    /**
646
     * Starts converting this zombie into a villager. The zombie converts into a villager after the specified time in
647
     * ticks.
648
     */
649
    protected void startConversion(int ticks)
650
    {
651
        this.conversionTime = ticks;
652
        this.getDataWatcher().updateObject(14, Byte.valueOf((byte)1));
653
        this.removePotionEffect(Potion.weakness.id);
654
        this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, ticks, Math.min(this.worldObj.getDifficulty().getDifficultyId() - 1, 0)));
655
        this.worldObj.setEntityState(this, (byte)16);
656
    }
657
658
    public void handleStatusUpdate(byte id)
659
    {
660
        if (id == 16)
661
        {
662
            if (!this.isSilent())
663
            {
664
                this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "mob.zombie.remedy", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false);
665
            }
666
        }
667
        else
668
        {
669
            super.handleStatusUpdate(id);
670
        }
671
    }
672
673
    /**
674
     * Determines if an entity can be despawned, used on idle far away entities
675
     */
676
    protected boolean canDespawn()
677
    {
678
        return !this.isConverting();
679
    }
680
681
    /**
682
     * Returns whether this zombie is in the process of converting to a villager
683
     */
684
    public boolean isConverting()
685
    {
686
        return this.getDataWatcher().getWatchableObjectByte(14) == 1;
687
    }
688
689
    /**
690
     * Convert this zombie into a villager.
691
     */
692
    protected void convertToVillager()
693
    {
694
        EntityVillager entityvillager = new EntityVillager(this.worldObj);
695
        entityvillager.copyLocationAndAnglesFrom(this);
696
        entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
697
        entityvillager.setLookingForHome();
698
699
        if (this.isChild())
700
        {
701
            entityvillager.setGrowingAge(-24000);
702
        }
703
704
        this.worldObj.removeEntity(this);
705
        entityvillager.setNoAI(this.isAIDisabled());
706
707
        if (this.hasCustomName())
708
        {
709
            entityvillager.setCustomNameTag(this.getCustomNameTag());
710
            entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
711
        }
712
713
        this.worldObj.spawnEntityInWorld(entityvillager);
714
        entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
715
        this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
716
    }
717
718
    /**
719
     * Return the amount of time decremented from conversionTime every tick.
720
     */
721
    protected int getConversionTimeBoost()
722
    {
723
        int i = 1;
724
725
        if (this.rand.nextFloat() < 0.01F)
726
        {
727
            int j = 0;
728
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
729
730
            for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
731
            {
732
                for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
733
                {
734
                    for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
735
                    {
736
                        Block block = this.worldObj.getBlockState(blockpos$mutableblockpos.set(k, l, i1)).getBlock();
737
738
                        if (block == Blocks.iron_bars || block == Blocks.bed)
739
                        {
740
                            if (this.rand.nextFloat() < 0.3F)
741
                            {
742
                                ++i;
743
                            }
744
745
                            ++j;
746
                        }
747
                    }
748
                }
749
            }
750
        }
751
752
        return i;
753
    }
754
755
    /**
756
     * sets the size of the entity to be half of its current size if true.
757
     */
758
    public void setChildSize(boolean isChild)
759
    {
760
        this.multiplySize(isChild ? 0.5F : 1.0F);
761
    }
762
763
    /**
764
     * Sets the width and height of the entity. Args: width, height
765
     */
766
    protected final void setSize(float width, float height)
767
    {
768
        boolean flag = this.zombieWidth > 0.0F && this.zombieHeight > 0.0F;
769
        this.zombieWidth = width;
770
        this.zombieHeight = height;
771
772
        if (!flag)
773
        {
774
            this.multiplySize(1.0F);
775
        }
776
    }
777
778
    /**
779
     * Multiplies the height and width by the provided float.
780
     */
781
    protected final void multiplySize(float size)
782
    {
783
        super.setSize(this.zombieWidth * size, this.zombieHeight * size);
784
    }
785
786
    /**
787
     * Returns the Y Offset of this entity.
788
     */
789
    public double getYOffset()
790
    {
791
        return this.isChild() ? 0.0D : -0.35D;
792
    }
793
794
    /**
795
     * Called when the mob's health reaches 0.
796
     */
797
    public void onDeath(DamageSource cause)
798
    {
799
        super.onDeath(cause);
800
801
        if (cause.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
802
        {
803
            ((EntityCreeper)cause.getEntity()).func_175493_co();
804
            this.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
805
        }
806
    }
807
808
    class GroupData implements IEntityLivingData
809
    {
810
        public boolean isChild;
811
        public boolean isVillager;
812
813
        private GroupData(boolean isBaby, boolean isVillagerZombie)
814
        {
815
            this.isChild = false;
816
            this.isVillager = false;
817
            this.isChild = isBaby;
818
            this.isVillager = isVillagerZombie;
819
        }
820
    }
821
}
822

Deobfuscated MCP 1.8.9 source of EntityZombie from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/monster/EntityZombie.java), stored verbatim.