Skip to content

Commit

Permalink
Improved shielding mechanics.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvionKirito committed Mar 29, 2023
1 parent 067222e commit 32915bb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/main/java/adris/altoclef/chains/FoodChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ public float getPriority(AltoClef mod) {
_requestFillup = false;
}
if (hasFood && (needsToEat() || _requestFillup) && _cachedPerfectFood.isPresent() &&
!mod.getMLGBucketChain().isChorusFruiting() && !mod.getPlayer().isBlocking() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
!mod.getMLGBucketChain().isChorusFruiting() && !mod.getPlayer().isBlocking()) {
Item toUse = _cachedPerfectFood.get();
// Make sure we're not facing a container
if (!LookHelper.tryAvoidingInteractable(mod)) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/adris/altoclef/chains/MobDefenseChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ public float getPriorityInner(AltoClef mod) {
if (blowingUp != null) {
if (!mod.getFoodChain().needsToEat() && (mod.getItemStorage().hasItem(Items.SHIELD) ||
mod.getItemStorage().hasItemInOffhand(Items.SHIELD)) &&
!mod.getEntityTracker().entityFound(PotionEntity.class) && _runAwayTask == null &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
!mod.getEntityTracker().entityFound(PotionEntity.class) && _runAwayTask == null) {
_doingFunkyStuff = true;
mod.getClientBaritone().getPathingBehavior().softCancelIfSafe();
LookHelper.lookAt(mod, blowingUp.getEyePos());
ItemStack shieldSlot = StorageHelper.getItemStackInSlot(PlayerSlot.OFFHAND_SLOT);
if (shieldSlot.getItem() != Items.SHIELD) {
Expand All @@ -206,9 +204,12 @@ public float getPriorityInner(AltoClef mod) {
}
}
// Block projectiles with shield
PlayerSlot offhandSlot = PlayerSlot.OFFHAND_SLOT;
Item offhandItem = StorageHelper.getItemStackInSlot(offhandSlot).getItem();
if (!mod.getFoodChain().needsToEat() && mod.getModSettings().isDodgeProjectiles() && isProjectileClose(mod) &&
(mod.getItemStorage().hasItem(Items.SHIELD) || mod.getItemStorage().hasItemInOffhand(Items.SHIELD)) &&
!mod.getEntityTracker().entityFound(PotionEntity.class) && _runAwayTask == null) {
!mod.getEntityTracker().entityFound(PotionEntity.class) && _runAwayTask == null &&
!mod.getPlayer().getItemCooldownManager().isCoolingDown(offhandItem)) {
ItemStack shieldSlot = StorageHelper.getItemStackInSlot(PlayerSlot.OFFHAND_SLOT);
if (shieldSlot.getItem() != Items.SHIELD) {
mod.getSlotHandler().forceEquipItemToOffhand(Items.SHIELD);
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/adris/altoclef/control/KillAura.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void setRange(double range) {
}

public void tickEnd(AltoClef mod) {
PlayerSlot offhandSlot = PlayerSlot.OFFHAND_SLOT;
Item offhandItem = StorageHelper.getItemStackInSlot(offhandSlot).getItem();
Optional<Entity> entities = _targets.stream().min(StlHelper.compareValues(entity -> entity.squaredDistanceTo(mod.getPlayer())));
if (entities.isPresent() && mod.getPlayer().getHealth() >= 10 &&
!mod.getEntityTracker().entityFound(PotionEntity.class) && !mod.getFoodChain().needsToEat() &&
Expand All @@ -79,7 +81,7 @@ public void tickEnd(AltoClef mod) {
entities.get().squaredDistanceTo(mod.getPlayer()) < 40) &&
!mod.getMLGBucketChain().isFallingOhNo(mod) && mod.getMLGBucketChain().doneMLG() &&
!mod.getMLGBucketChain().isChorusFruiting() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
!mod.getPlayer().getItemCooldownManager().isCoolingDown(offhandItem)) {
if (entities.get().getClass() != CreeperEntity.class && entities.get().getClass() != HoglinEntity.class &&
entities.get().getClass() != ZoglinEntity.class && entities.get().getClass() != WardenEntity.class &&
entities.get().getClass() != WitherEntity.class) {
Expand Down Expand Up @@ -111,8 +113,7 @@ public void tickEnd(AltoClef mod) {
performDelayedAttack(mod);
} else {
if (!mod.getFoodChain().needsToEat() && !mod.getMLGBucketChain().isFallingOhNo(mod) &&
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting()) {
// Attack force mobs ALWAYS.
if (_forceHit != null) {
attack(mod, _forceHit, true);
Expand All @@ -137,8 +138,7 @@ public void tickEnd(AltoClef mod) {

private void performDelayedAttack(AltoClef mod) {
if (!mod.getFoodChain().needsToEat() && !mod.getMLGBucketChain().isFallingOhNo(mod) &&
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting()) {
if (_forceHit != null) {
attack(mod, _forceHit, true);
}
Expand All @@ -159,8 +159,7 @@ private void performDelayedAttack(AltoClef mod) {

private void performFastestAttack(AltoClef mod) {
if (!mod.getFoodChain().needsToEat() && !mod.getMLGBucketChain().isFallingOhNo(mod) &&
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
mod.getMLGBucketChain().doneMLG() && !mod.getMLGBucketChain().isChorusFruiting()) {
// Just attack whenever you can
for (Entity entity : _targets) {
attack(mod, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private ClickResponse rightClick(AltoClef mod) {

// Don't interact if baritone can't interact.
if (mod.getExtraBaritoneSettings().isInteractionPaused() || mod.getFoodChain().needsToEat() ||
mod.getPlayer().isBlocking() || !mod.getClientBaritone().getPathingBehavior().isSafeToCancel())
mod.getPlayer().isBlocking())
return ClickResponse.WAIT_FOR_CLICK;

// We can't interact while a screen is open.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ protected Task onTick(AltoClef mod) {
Blocks.SNOW ? new GoalBlock(_pos) : new GoalNear(_pos, 1));
}
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ protected Task onTick(AltoClef mod) {
if (mod.getControllerExtras().inRange(entity) && result != null &&
result.getType() == HitResult.Type.ENTITY && !mod.getFoodChain().needsToEat() &&
!mod.getMLGBucketChain().isFallingOhNo(mod) && mod.getMLGBucketChain().doneMLG() &&
!mod.getMLGBucketChain().isChorusFruiting() &&
mod.getClientBaritone().getPathingBehavior().isSafeToCancel()) {
!mod.getMLGBucketChain().isChorusFruiting()) {
_progress.reset();
return onEntityInteract(mod, entity);
} else if (!tooClose) {
Expand Down

0 comments on commit 32915bb

Please sign in to comment.