-
Notifications
You must be signed in to change notification settings - Fork 9
/
EntityFriendlyZombie.java
125 lines (109 loc) · 3.62 KB
/
EntityFriendlyZombie.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package net.minecraft.src;
public class EntityFriendlyZombie extends EntityFriendlyMob
{
public EntityFriendlyZombie(World par1World)
{
super(par1World);
this.texture = "/mob/zombie.png";
this.moveSpeed = 0.23F;
this.attackStrength = 4;
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, this.moveSpeed, false));
this.tasks.addTask(3, new EntityFriendlyAIFollowPlayer(this, this.moveSpeed, 10.0F, 2.0F));
this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));
this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, this.moveSpeed, false));
this.tasks.addTask(6, new EntityAIWander(this, this.moveSpeed));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(7, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
targetTasks.addTask(2, new EntityFriendlyAIPlayerHurtTarget(this));
targetTasks.addTask(2, new EntityFriendlyAIPlayerHurtByTarget(this));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false));
}
public int getMaxHealth()
{
return 20;
}
/**
* Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
*/
public int getTotalArmorValue()
{
return 2;
}
/**
* Returns true if the newer Entity AI code should be run
*/
protected boolean isAIEnabled()
{
return true;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
if (this.worldObj.isDaytime() && !this.worldObj.isRemote)
{
float var1 = this.getBrightness(1.0F);
if (var1 > 0.5F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F)
{
this.setFire(8);
}
}
super.onLivingUpdate();
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.zombie";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.zombiehurt";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.zombiedeath";
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.rottenFlesh.shiftedIndex;
}
/**
* Get this Entity's EnumCreatureAttribute
*/
public EnumCreatureAttribute getCreatureAttribute()
{
return EnumCreatureAttribute.UNDEAD;
}
protected void dropRareDrop(int par1)
{
switch (this.rand.nextInt(4))
{
case 0:
this.dropItem(Item.swordSteel.shiftedIndex, 1);
break;
case 1:
this.dropItem(Item.helmetSteel.shiftedIndex, 1);
break;
case 2:
this.dropItem(Item.ingotIron.shiftedIndex, 1);
break;
case 3:
this.dropItem(Item.shovelSteel.shiftedIndex, 1);
}
}
}