File tree 5 files changed +15
-11
lines changed
src/main/java/com/github/alexthe666/iceandfire/entity
5 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -286,7 +286,8 @@ public void aiStep() {
286
286
}
287
287
if (this .getAnimation () == ANIMATION_KICK && this .getTarget () != null && this .distanceToSqr (this .getTarget ()) < 14D && this .getAnimationTick () == 12 ) {
288
288
this .getTarget ().hurt (this .level ().damageSources ().mobAttack (this ), (float ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue ());
289
- this .getTarget ().knockback (2 , this .getX () - this .getTarget ().getX (), this .getZ () - this .getTarget ().getZ ());
289
+ if (this .getTarget () != null )
290
+ this .getTarget ().knockback (2 , this .getX () - this .getTarget ().getX (), this .getZ () - this .getTarget ().getZ ());
290
291
291
292
}
292
293
if (this .getAnimation () != ANIMATION_EATPLAYER && this .getTarget () != null && !this .getPassengers ().isEmpty () && this .getPassengers ().contains (this .getTarget ())) {
Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ public void aiStep() {
139
139
this .lookAt (this .getTarget (), 360 , 80 );
140
140
if (this .getAnimation () == ANIMATION_BITE && this .getAnimationTick () == 6 ) {
141
141
this .getTarget ().hurt (level ().damageSources ().mobAttack (this ), (float ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue ());
142
- this .getTarget ().knockback (0.25F , this .getX () - this .getTarget ().getX (), this .getZ () - this .getTarget ().getZ ());
142
+ if (this .getTarget () != null )
143
+ this .getTarget ().knockback (0.25F , this .getX () - this .getTarget ().getX (), this .getZ () - this .getTarget ().getZ ());
143
144
}
144
145
}
145
146
Original file line number Diff line number Diff line change @@ -203,15 +203,14 @@ public void aiStep() {
203
203
if (this .getAnimation () == ANIMATION_STING && this .getTarget () != null && this .getAnimationTick () == 6 ) {
204
204
if (this .getAttackBounds ().intersects (this .getTarget ().getBoundingBox ())) {
205
205
LivingEntity attackTarget = this .getTarget ();
206
- this . getTarget () .hurt (this .level ().damageSources ().mobAttack (this ), ((int ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue () * 2 ));
207
- this . getTarget () .addEffect (new MobEffectInstance (MobEffects .POISON , 200 , 2 ));
208
- this . getTarget () .hasImpulse = true ;
206
+ attackTarget .hurt (this .level ().damageSources ().mobAttack (this ), ((int ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue () * 2 ));
207
+ attackTarget .addEffect (new MobEffectInstance (MobEffects .POISON , 200 , 2 ));
208
+ attackTarget .hasImpulse = true ;
209
209
float f = Mth .sqrt ((float ) (0.5 * 0.5 + 0.5 * 0.5 ));
210
- this .getTarget ().hasImpulse = true ;
211
210
attackTarget .setDeltaMovement (attackTarget .getDeltaMovement ().multiply (0.5D , 1 , 0.5D ));
212
211
attackTarget .setDeltaMovement (attackTarget .getDeltaMovement ().add (-0.5 / f * 4 , 1 , -0.5 / f * 4 ));
213
212
214
- if (this . getTarget () .onGround ()) {
213
+ if (attackTarget .onGround ()) {
215
214
attackTarget .setDeltaMovement (attackTarget .getDeltaMovement ().add (0 , 0.4 , 0 ));
216
215
}
217
216
}
Original file line number Diff line number Diff line change @@ -209,7 +209,9 @@ public void aiStep() {
209
209
double dist = this .distanceToSqr (this .getTarget ());
210
210
if (dist < attackDistance ()) {
211
211
this .getTarget ().hurt (level ().damageSources ().mobAttack (this ), ((int ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue () * 2 ));
212
- this .getTarget ().addEffect (new MobEffectInstance (MobEffects .POISON , 70 , 1 ));
212
+ // After calling hurt the target can become null due to forge hooks
213
+ if (this .getTarget () != null )
214
+ this .getTarget ().addEffect (new MobEffectInstance (MobEffects .POISON , 70 , 1 ));
213
215
}
214
216
}
215
217
}
Original file line number Diff line number Diff line change @@ -360,9 +360,10 @@ public void aiStep() {
360
360
this .getTarget ().hurt (this .level ().damageSources ().mobAttack (this ), (float ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue ());
361
361
}
362
362
if (this .getAnimation () == ANIMATION_STRIKE_HORIZONTAL && this .getTarget () != null && this .distanceToSqr (this .getTarget ()) < 4D && this .getAnimationTick () == 10 && this .deathTime <= 0 ) {
363
- this .getTarget ().hurt (this .level ().damageSources ().mobAttack (this ), (float ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue ());
363
+ LivingEntity target = this .getTarget ();
364
+ target .hurt (this .level ().damageSources ().mobAttack (this ), (float ) this .getAttribute (Attributes .ATTACK_DAMAGE ).getValue ());
364
365
float f1 = 0.5F ;
365
- float f2 = this . getTarget () .zza ;
366
+ float f2 = target .zza ;
366
367
float f3 = 0.6F ;
367
368
float f4 = Mth .sqrt (f2 * f2 + f3 * f3 );
368
369
@@ -377,7 +378,7 @@ public void aiStep() {
377
378
float f6 = Mth .cos (this .getYRot () * 0.017453292F );
378
379
// float f7 = f2 * f6 - f3 * f5;
379
380
// float f8 = f3 * f6 + f2 * f5;
380
- this . getTarget () .setDeltaMovement (f5 , f6 , 0.4F );
381
+ target .setDeltaMovement (f5 , f6 , 0.4F );
381
382
}
382
383
if (this .getNavigation ().isDone () && this .getTarget () != null && this .distanceToSqr (this .getTarget ()) > 3 && this .distanceToSqr (this .getTarget ()) < 30 && this .level ().getGameRules ().getBoolean (GameRules .RULE_MOBGRIEFING )) {
383
384
this .lookAt (this .getTarget (), 30 , 30 );
You can’t perform that action at this time.
0 commit comments