-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wither Minions no longer strafe when attacking
- Loading branch information
Showing
7 changed files
with
157 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/main/java/insane96mcp/progressivebosses/module/wither/ai/RangedMinionAttackGoal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package insane96mcp.progressivebosses.module.wither.ai; | ||
|
||
import insane96mcp.progressivebosses.module.wither.entity.WitherMinion; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.ai.goal.Goal; | ||
import net.minecraft.world.entity.projectile.ProjectileUtil; | ||
import net.minecraft.world.item.BowItem; | ||
|
||
import java.util.EnumSet; | ||
|
||
// Same as RangedBowAttackGoal but without the strafing | ||
public class RangedMinionAttackGoal extends Goal { | ||
private final WitherMinion mob; | ||
private final double speedModifier; | ||
private int attackIntervalMin; | ||
private final float attackRadiusSqr; | ||
private int attackTime = -1; | ||
private int seeTime; | ||
|
||
public RangedMinionAttackGoal(WitherMinion p_25792_, double p_25793_, int p_25794_, float p_25795_) { | ||
this.mob = p_25792_; | ||
this.speedModifier = p_25793_; | ||
this.attackIntervalMin = p_25794_; | ||
this.attackRadiusSqr = p_25795_ * p_25795_; | ||
this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); | ||
} | ||
|
||
public void setMinAttackInterval(int p_25798_) { | ||
this.attackIntervalMin = p_25798_; | ||
} | ||
|
||
public boolean canUse() { | ||
return this.mob.getTarget() != null && this.isHoldingBow(); | ||
} | ||
|
||
protected boolean isHoldingBow() { | ||
return this.mob.isHolding(is -> is.getItem() instanceof BowItem); | ||
} | ||
|
||
public boolean canContinueToUse() { | ||
return (this.canUse() || !this.mob.getNavigation().isDone()) && this.isHoldingBow(); | ||
} | ||
|
||
public void start() { | ||
super.start(); | ||
this.mob.setAggressive(true); | ||
} | ||
|
||
public void stop() { | ||
super.stop(); | ||
this.mob.setAggressive(false); | ||
this.seeTime = 0; | ||
this.attackTime = -1; | ||
this.mob.stopUsingItem(); | ||
} | ||
|
||
public boolean requiresUpdateEveryTick() { | ||
return true; | ||
} | ||
|
||
public void tick() { | ||
LivingEntity livingentity = this.mob.getTarget(); | ||
if (livingentity != null) { | ||
double d0 = this.mob.distanceToSqr(livingentity.getX(), livingentity.getY(), livingentity.getZ()); | ||
boolean flag = this.mob.getSensing().hasLineOfSight(livingentity); | ||
boolean flag1 = this.seeTime > 0; | ||
if (flag != flag1) { | ||
this.seeTime = 0; | ||
} | ||
|
||
if (flag) { | ||
++this.seeTime; | ||
} else { | ||
--this.seeTime; | ||
} | ||
|
||
if (!(d0 > (double)this.attackRadiusSqr) && this.seeTime >= 1) { | ||
this.mob.getNavigation().stop(); | ||
} else { | ||
this.mob.getNavigation().moveTo(livingentity, this.speedModifier); | ||
} | ||
|
||
this.mob.getLookControl().setLookAt(livingentity, 30.0F, 30.0F); | ||
|
||
if (this.mob.isUsingItem()) { | ||
if (!flag && this.seeTime < -60) { | ||
this.mob.stopUsingItem(); | ||
} else if (flag) { | ||
int i = this.mob.getTicksUsingItem(); | ||
if (i >= 20) { | ||
this.mob.stopUsingItem(); | ||
this.mob.performRangedAttack(livingentity, BowItem.getPowerForTime(i)); | ||
this.attackTime = this.attackIntervalMin; | ||
} | ||
} | ||
} else if (--this.attackTime <= 0 && this.seeTime >= -60) { | ||
this.mob.startUsingItem(ProjectileUtil.getWeaponHoldingHand(this.mob, item -> item instanceof BowItem)); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters