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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
package net.minecraft.server;
public class EntityWolf extends EntityTameableAnimal {
private float bq;
private float br;
private boolean bs;
private boolean bt;
private float bu;
private float bv;
public EntityWolf(World world) {
super(world);
this.a(0.6F, 0.8F);
this.getNavigation().a(true);
this.goalSelector.a(1, new PathfinderGoalFloat(this));
this.goalSelector.a(2, this.bp);
this.goalSelector.a(3, new PathfinderGoalLeapAtTarget(this, 0.4F));
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, true));
this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.goalSelector.a(6, new PathfinderGoalBreed(this, 1.0D));
this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
this.goalSelector.a(8, new PathfinderGoalBeg(this, 8.0F));
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
this.goalSelector.a(9, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this));
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
this.targetSelector.a(3, new PathfinderGoalHurtByTarget(this, true));
this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed(this, EntitySheep.class, 200, false));
this.setTamed(false);
}
protected void aD() {
super.aD();
this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D);
if (this.isTamed()) {
this.getAttributeInstance(GenericAttributes.a).setValue(20.0D);
} else {
this.getAttributeInstance(GenericAttributes.a).setValue(8.0D);
}
}
public boolean bk() {
return true;
}
public void setGoalTarget(EntityLiving entityliving) {
super.setGoalTarget(entityliving);
if (entityliving == null) {
this.setAngry(false);
} else if (!this.isTamed()) {
this.setAngry(true);
}
}
protected void bp() {
this.datawatcher.watch(18, Float.valueOf(this.getHealth()));
}
protected void c() {
super.c();
this.datawatcher.a(18, new Float(this.getHealth()));
this.datawatcher.a(19, new Byte((byte) 0));
this.datawatcher.a(20, new Byte((byte) BlockCloth.b(1)));
}
protected void a(int i, int j, int k, Block block) {
this.makeSound("mob.wolf.step", 0.15F, 1.0F);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("Angry", this.isAngry());
nbttagcompound.setByte("CollarColor", (byte) this.getCollarColor());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setAngry(nbttagcompound.getBoolean("Angry"));
if (nbttagcompound.hasKeyOfType("CollarColor", 99)) {
this.setCollarColor(nbttagcompound.getByte("CollarColor"));
}
}
protected String t() {
// CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2)
return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < (this.getMaxHealth() / 2) ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
protected String aT() {
return "mob.wolf.hurt";
}
protected String aU() {
return "mob.wolf.death";
}
protected float bf() {
return 0.4F;
}
protected Item getLoot() {
return Item.d(-1);
}
public void e() {
super.e();
if (!this.world.isStatic && this.bs && !this.bt && !this.bQ() && this.onGround) {
this.bt = true;
this.bu = 0.0F;
this.bv = 0.0F;
this.world.broadcastEntityEffect(this, (byte) 8);
}
}
public void h() {
super.h();
this.br = this.bq;
if (this.ci()) {
this.bq += (1.0F - this.bq) * 0.4F;
} else {
this.bq += (0.0F - this.bq) * 0.4F;
}
if (this.ci()) {
this.g = 10;
}
if (this.L()) {
this.bs = true;
this.bt = false;
this.bu = 0.0F;
this.bv = 0.0F;
} else if ((this.bs || this.bt) && this.bt) {
if (this.bu == 0.0F) {
this.makeSound("mob.wolf.shake", this.bf(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
this.bv = this.bu;
this.bu += 0.05F;
if (this.bv >= 2.0F) {
this.bs = false;
this.bt = false;
this.bv = 0.0F;
this.bu = 0.0F;
}
if (this.bu > 0.4F) {
float f = (float) this.boundingBox.b;
int i = (int) (MathHelper.sin((this.bu - 0.4F) * 3.1415927F) * 7.0F);
for (int j = 0; j < i; ++j) {
float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
float f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
this.world.addParticle("splash", this.locX + (double) f1, (double) (f + 0.8F), this.locZ + (double) f2, this.motX, this.motY, this.motZ);
}
}
}
}
public float getHeadHeight() {
return this.length * 0.8F;
}
public int x() {
return this.isSitting() ? 20 : super.x();
}
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else {
Entity entity = damagesource.getEntity();
this.bp.setSitting(false);
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
f = (f + 1.0F) / 2.0F;
}
return super.damageEntity(damagesource, f);
}
}
public boolean m(Entity entity) {
int i = this.isTamed() ? 4 : 2;
return entity.damageEntity(DamageSource.mobAttack(this), (float) i);
}
public void setTamed(boolean flag) {
super.setTamed(flag);
if (flag) {
this.getAttributeInstance(GenericAttributes.a).setValue(20.0D);
} else {
this.getAttributeInstance(GenericAttributes.a).setValue(8.0D);
}
}
public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (this.isTamed()) {
if (itemstack != null) {
if (itemstack.getItem() instanceof ItemFood) {
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.i() && this.datawatcher.getFloat(18) < 20.0F) {
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
this.heal((float) itemfood.getNutrition(itemstack));
if (itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
return true;
}
} else if (itemstack.getItem() == Items.INK_SACK) {
int i = BlockCloth.b(itemstack.getData());
if (i != this.getCollarColor()) {
this.setCollarColor(i);
if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
return true;
}
}
}
if (entityhuman.getName().equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) {
this.bp.setSitting(!this.isSitting());
this.bd = false;
this.setPathEntity((PathEntity) null);
this.setTarget((Entity) null);
this.setGoalTarget((EntityLiving) null);
}
} else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) {
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
if (itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
if (!this.world.isStatic) {
// CraftBukkit - added event call and isCancelled check.
if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.setTamed(true);
this.setPathEntity((PathEntity) null);
this.setGoalTarget((EntityLiving) null);
this.bp.setSitting(true);
this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
this.setOwnerName(entityhuman.getName());
this.i(true);
this.world.broadcastEntityEffect(this, (byte) 7);
} else {
this.i(false);
this.world.broadcastEntityEffect(this, (byte) 6);
}
}
return true;
}
return super.a(entityhuman);
}
public boolean c(ItemStack itemstack) {
return itemstack == null ? false : (!(itemstack.getItem() instanceof ItemFood) ? false : ((ItemFood) itemstack.getItem()).i());
}
public int bz() {
return 8;
}
public boolean isAngry() {
return (this.datawatcher.getByte(16) & 2) != 0;
}
public void setAngry(boolean flag) {
byte b0 = this.datawatcher.getByte(16);
if (flag) {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 2)));
} else {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -3)));
}
}
public int getCollarColor() {
return this.datawatcher.getByte(20) & 15;
}
public void setCollarColor(int i) {
this.datawatcher.watch(20, Byte.valueOf((byte) (i & 15)));
}
public EntityWolf b(EntityAgeable entityageable) {
EntityWolf entitywolf = new EntityWolf(this.world);
String s = this.getOwnerName();
if (s != null && s.trim().length() > 0) {
entitywolf.setOwnerName(s);
entitywolf.setTamed(true);
}
return entitywolf;
}
public void m(boolean flag) {
if (flag) {
this.datawatcher.watch(19, Byte.valueOf((byte) 1));
} else {
this.datawatcher.watch(19, Byte.valueOf((byte) 0));
}
}
public boolean mate(EntityAnimal entityanimal) {
if (entityanimal == this) {
return false;
} else if (!this.isTamed()) {
return false;
} else if (!(entityanimal instanceof EntityWolf)) {
return false;
} else {
EntityWolf entitywolf = (EntityWolf) entityanimal;
return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.cc() && entitywolf.cc());
}
}
public boolean ci() {
return this.datawatcher.getByte(19) == 1;
}
protected boolean isTypeNotPersistent() {
return !this.isTamed(); // CraftBukkit
}
public boolean a(EntityLiving entityliving, EntityLiving entityliving1) {
if (!(entityliving instanceof EntityCreeper) && !(entityliving instanceof EntityGhast)) {
if (entityliving instanceof EntityWolf) {
EntityWolf entitywolf = (EntityWolf) entityliving;
if (entitywolf.isTamed() && entitywolf.getOwner() == entityliving1) {
return false;
}
}
return entityliving instanceof EntityHuman && entityliving1 instanceof EntityHuman && !((EntityHuman) entityliving1).a((EntityHuman) entityliving) ? false : !(entityliving instanceof EntityHorse) || !((EntityHorse) entityliving).isTame();
} else {
return false;
}
}
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}
}
|