@@ -510,6 +510,26 @@ export default abstract class PathingEntity extends Entity {
510510 }
511511 }
512512
513+ setFaceEntity ( ) : void {
514+ const oldEntity = this . faceEntity ;
515+ if ( this . target instanceof Player ) {
516+ const playerSlot : number = this . target . slot + 32768 ;
517+ if ( this . faceEntity !== playerSlot ) {
518+ this . faceEntity = playerSlot ;
519+ }
520+ } else if ( this . target instanceof Npc ) {
521+ const nid : number = this . target . nid ;
522+ if ( this . faceEntity !== nid ) {
523+ this . faceEntity = nid ;
524+ }
525+ } else {
526+ this . faceEntity = - 1 ;
527+ }
528+ if ( this . faceEntity !== oldEntity ) {
529+ this . masks |= this . entitymask ;
530+ }
531+ }
532+
513533 setInteraction ( interaction : Interaction , target : Entity , op : TargetOp , com ?: number ) : boolean {
514534 if ( ! target . isValid ( this instanceof Player ? this . hash64 : undefined ) ) {
515535 return false ;
@@ -530,19 +550,7 @@ export default abstract class PathingEntity extends Entity {
530550
531551 this . focus ( CoordGrid . fine ( target . x , target . width ) , CoordGrid . fine ( target . z , target . length ) , target instanceof NonPathingEntity && interaction === Interaction . ENGINE ) ;
532552
533- if ( target instanceof Player ) {
534- const playerSlot : number = target . slot + 32768 ;
535- if ( this . faceEntity !== playerSlot ) {
536- this . faceEntity = playerSlot ;
537- this . masks |= this . entitymask ;
538- }
539- } else if ( target instanceof Npc ) {
540- const nid : number = target . nid ;
541- if ( this . faceEntity !== nid ) {
542- this . faceEntity = nid ;
543- this . masks |= this . entitymask ;
544- }
545- } else {
553+ if ( target instanceof NonPathingEntity ) {
546554 this . targetX = CoordGrid . fine ( target . x , target . width ) ;
547555 this . targetZ = CoordGrid . fine ( target . z , target . length ) ;
548556 }
@@ -614,10 +622,7 @@ export default abstract class PathingEntity extends Entity {
614622 this . faceSquareX = - 1 ;
615623 this . faceSquareZ = - 1 ;
616624
617- if ( ! this . target && this . faceEntity !== - 1 ) {
618- this . masks |= this . entitymask ;
619- this . faceEntity = - 1 ;
620- }
625+ this . setFaceEntity ( ) ;
621626 }
622627
623628 private takeStep ( ) : number | null {
0 commit comments