@@ -59,9 +59,16 @@ public class AshAttackGoal extends Goal {
5959 private double targetY ;
6060 private double targetZ ;
6161 private int updateCountdownTicks ;
62- private int field_24667 ;
62+ private int attackCd ;
6363 private final int attackIntervalTicks = 20 ;
6464 private long lastUpdateTime ;
65+ private AttackType lastAttack ;
66+
67+ private enum AttackType {
68+ MELEE ,
69+ ASH ,
70+ NONE
71+ }
6572
6673 public AshAttackGoal (BlackenedEntity mob , double speed , boolean pauseWhenMobIdle ) {
6774 this .mob = mob ;
@@ -119,7 +126,8 @@ public void start() {
119126 this .mob .getNavigation ().startMovingAlong (this .path , this .speed );
120127 this .mob .setAttacking (true );
121128 this .updateCountdownTicks = 0 ;
122- this .field_24667 = 0 ;
129+ this .attackCd = 0 ;
130+ this .lastAttack = AttackType .NONE ;
123131 }
124132
125133 public void stop () {
@@ -129,6 +137,8 @@ public void stop() {
129137 }
130138
131139 this .mob .setAttacking (false );
140+ this .mob .setMeleeAttacking (false );
141+ this .mob .setAshAttacking (false );
132142 this .mob .getNavigation ().stop ();
133143 }
134144
@@ -153,50 +163,53 @@ public void tick() {
153163 }
154164 }
155165
156- this .field_24667 = Math .max (this .field_24667 - 1 , 0 );
166+ this .attackCd = Math .max (this .attackCd - 1 , 0 );
157167 this .attack (livingEntity , d );
158168 }
159169
160170 protected void attack (LivingEntity target , double squaredDistance ) {
161171 double d = this .getSquaredMaxAttackDistance (target );
162172 double e = this .getSquaredCloseAttackDistance (target );
163- if (this .field_24667 <= 0 ) {
164- if (squaredDistance <= e ) {
165- this .method_28346 ();
166- this .mob .swingHand (Hand .MAIN_HAND );
167- this .mob .setMeleeAttacking (true );
168- this .mob .tryAttack (target );
169- } else if (squaredDistance <= d ) {
170- this .method_28346 ();
171- this .mob .swingHand (Hand .MAIN_HAND );
172- this .mob .setAshAttacking (true );
173- this .mob .tryAshAttack (target );
174- }
173+ if (squaredDistance <= e &&
174+ (this .lastAttack == AttackType .NONE && this .getAttackCd () <= 0 ) ||
175+ (this .lastAttack == AttackType .MELEE && this .getAttackCd () <= 0 ) ||
176+ (this .lastAttack == AttackType .ASH && this .getAttackCd () <= 30 )) {
177+ this .resetAttackCd ();
178+ this .mob .swingHand (Hand .MAIN_HAND );
179+ this .mob .setMeleeAttacking (true );
180+ this .mob .setAshAttacking (false );
181+ this .lastAttack = AttackType .MELEE ;
182+ this .mob .tryAttack (target );
183+ } else if (squaredDistance <= d &&
184+ (this .lastAttack == AttackType .NONE && this .getAttackCd () <= 0 ) ||
185+ (this .lastAttack == AttackType .MELEE && this .getAttackCd () <= 30 ) ||
186+ (this .lastAttack == AttackType .ASH && this .getAttackCd () <= 0 )) {
187+ this .resetAttackCd ();
188+ this .mob .swingHand (Hand .MAIN_HAND );
189+ this .mob .setAshAttacking (true );
190+ this .mob .setMeleeAttacking (false );
191+ this .lastAttack = AttackType .ASH ;
192+ this .mob .tryAshAttack (target );
193+ } else if (squaredDistance > d || this .getAttackCd () <= 0 ) {
194+ this .mob .setAshAttacking (false );
195+ this .mob .setMeleeAttacking (false );
196+ this .lastAttack = AttackType .NONE ;
175197 }
176-
177- }
178-
179- protected void method_28346 () {
180- this .field_24667 = 40 ;
181- }
182-
183- protected boolean method_28347 () {
184- return this .field_24667 <= 0 ;
185198 }
186199
187- protected int method_28348 () {
188- return this .field_24667 ;
200+ protected void resetAttackCd () {
201+ this .attackCd = 60 ;
189202 }
190203
191- protected int method_28349 () {
192- return 20 ;
204+ protected int getAttackCd () {
205+ return this . attackCd ;
193206 }
194207
195208 protected double getSquaredMaxAttackDistance (LivingEntity entity ) {
196209 return (double )(this .mob .getWidth () * 4.0F * this .mob .getWidth () * 4.0F + entity .getWidth ());
197210 }
198211
199212 protected double getSquaredCloseAttackDistance (LivingEntity entity ) {
200- return (double )(this .mob .getWidth () * 1.5F * this .mob .getWidth () * 1.5F + entity .getWidth ());
213+ return (double )(this .mob .getWidth () * 2.0F * this .mob .getWidth () * 2.0F + entity .getWidth ());
201214 }
202215}
0 commit comments