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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
package net.minecraft.server;
import java.util.Calendar;
import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
public class EntitySkeleton extends EntityMonster implements IRangedEntity {
private PathfinderGoalArrowAttack bp = new PathfinderGoalArrowAttack(this, 1.0D, 20, 60, 15.0F);
private PathfinderGoalMeleeAttack bq = new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.2D, false);
public EntitySkeleton(World world) {
super(world);
this.goalSelector.a(1, new PathfinderGoalFloat(this));
this.goalSelector.a(2, new PathfinderGoalRestrictSun(this));
this.goalSelector.a(3, new PathfinderGoalFleeSun(this, 1.0D));
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D));
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true));
if (world != null && !world.isStatic) {
this.bZ();
}
}
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.d).setValue(0.25D);
}
protected void c() {
super.c();
this.datawatcher.a(13, new Byte((byte) 0));
}
public boolean bk() {
return true;
}
protected String t() {
return "mob.skeleton.say";
}
protected String aT() {
return "mob.skeleton.hurt";
}
protected String aU() {
return "mob.skeleton.death";
}
protected void a(int i, int j, int k, Block block) {
this.makeSound("mob.skeleton.step", 0.15F, 1.0F);
}
public boolean n(Entity entity) {
if (super.n(entity)) {
if (this.getSkeletonType() == 1 && entity instanceof EntityLiving) {
((EntityLiving) entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 200));
}
return true;
} else {
return false;
}
}
public EnumMonsterType getMonsterType() {
return EnumMonsterType.UNDEAD;
}
public void e() {
if (this.world.w() && !this.world.isStatic) {
float f = this.d(1.0F);
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))) {
boolean flag = true;
ItemStack itemstack = this.getEquipment(4);
if (itemstack != null) {
if (itemstack.g()) {
itemstack.setData(itemstack.j() + this.random.nextInt(2));
if (itemstack.j() >= itemstack.l()) {
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);
if (!event.isCancelled()) {
this.setOnFire(event.getDuration());
}
// CraftBukkit end
}
}
}
if (this.world.isStatic && this.getSkeletonType() == 1) {
this.a(0.72F, 2.34F);
}
super.e();
}
public void ab() {
super.ab();
if (this.vehicle instanceof EntityCreature) {
EntityCreature entitycreature = (EntityCreature) this.vehicle;
this.aM = entitycreature.aM;
}
}
public void die(DamageSource damagesource) {
super.die(damagesource);
if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
double d0 = entityhuman.locX - this.locX;
double d1 = entityhuman.locZ - this.locZ;
if (d0 * d0 + d1 * d1 >= 2500.0D) {
entityhuman.a((Statistic) AchievementList.v);
}
}
}
protected Item getLoot() {
return Items.ARROW;
}
protected void dropDeathLoot(boolean flag, int i) {
int j;
int k;
if (this.getSkeletonType() == 1) {
j = this.random.nextInt(3 + i) - 1;
for (k = 0; k < j; ++k) {
this.a(Items.COAL, 1);
}
} else {
j = this.random.nextInt(3 + i);
for (k = 0; k < j; ++k) {
this.a(Items.ARROW, 1);
}
}
j = this.random.nextInt(3 + i);
for (k = 0; k < j; ++k) {
this.a(Items.BONE, 1);
}
}
protected void getRareDrop(int i) {
if (this.getSkeletonType() == 1) {
this.a(new ItemStack(Items.SKULL, 1, 1), 0.0F);
}
}
protected void bC() {
super.bC();
this.setEquipment(0, new ItemStack(Items.BOW));
}
public GroupDataEntity prepare(GroupDataEntity groupdataentity) {
groupdataentity = super.prepare(groupdataentity);
if (this.world.worldProvider instanceof WorldProviderHell && this.aI().nextInt(5) > 0) {
this.goalSelector.a(4, this.bq);
this.setSkeletonType(1);
this.setEquipment(0, new ItemStack(Items.STONE_SWORD));
this.getAttributeInstance(GenericAttributes.e).setValue(4.0D);
} else {
this.goalSelector.a(4, this.bp);
this.bC();
this.bD();
}
this.h(this.random.nextFloat() < 0.55F * this.world.b(this.locX, this.locY, this.locZ));
if (this.getEquipment(4) == null) {
Calendar calendar = this.world.V();
if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) {
this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.PUMPKIN));
this.dropChances[4] = 0.0F;
}
}
return groupdataentity;
}
public void bZ() {
this.goalSelector.a((PathfinderGoal) this.bq);
this.goalSelector.a((PathfinderGoal) this.bp);
ItemStack itemstack = this.be();
if (itemstack != null && itemstack.getItem() == Items.BOW) {
this.goalSelector.a(4, this.bp);
} else {
this.goalSelector.a(4, this.bq);
}
}
public void a(EntityLiving entityliving, float f) {
EntityArrow entityarrow = new EntityArrow(this.world, this, entityliving, 1.6F, (float) (14 - this.world.difficulty.a() * 4));
int i = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, this.be());
int j = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, this.be());
entityarrow.b((double) (f * 2.0F) + this.random.nextGaussian() * 0.25D + (double) ((float) this.world.difficulty.a() * 0.11F));
if (i > 0) {
entityarrow.b(entityarrow.e() + (double) i * 0.5D + 0.5D);
}
if (j > 0) {
entityarrow.setKnockbackStrength(j);
}
if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, this.be()) > 0 || this.getSkeletonType() == 1) {
// CraftBukkit start - call EntityCombustEvent
EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
entityarrow.setOnFire(event.getDuration());
}
// CraftBukkit end
}
// CraftBukkit start
org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.be(), entityarrow, 0.8F);
if (event.isCancelled()) {
event.getProjectile().remove();
return;
}
if (event.getProjectile() == entityarrow.getBukkitEntity()) {
world.addEntity(entityarrow);
}
// CraftBukkit end
this.makeSound("random.bow", 1.0F, 1.0F / (this.aI().nextFloat() * 0.4F + 0.8F));
// this.world.addEntity(entityarrow); // CraftBukkit - moved up
}
public int getSkeletonType() {
return this.datawatcher.getByte(13);
}
public void setSkeletonType(int i) {
this.datawatcher.watch(13, Byte.valueOf((byte) i));
this.fireProof = i == 1;
if (i == 1) {
this.a(0.72F, 2.34F);
} else {
this.a(0.6F, 1.8F);
}
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKeyOfType("SkeletonType", 99)) {
byte b0 = nbttagcompound.getByte("SkeletonType");
this.setSkeletonType(b0);
}
this.bZ();
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setByte("SkeletonType", (byte) this.getSkeletonType());
}
public void setEquipment(int i, ItemStack itemstack) {
super.setEquipment(i, itemstack);
if (!this.world.isStatic && i == 0) {
this.bZ();
}
}
public double ad() {
return super.ad() - 0.5D;
}
}
|