feat(combat): implement 1.8 block priority and void knockback priority in AutoWeapon#8432
Open
m1trenv0 wants to merge 4 commits into
Open
feat(combat): implement 1.8 block priority and void knockback priority in AutoWeapon#8432m1trenv0 wants to merge 4 commits into
m1trenv0 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR extends AutoWeapon’s weapon selection logic to prioritize legacy sword blocking (1.8-style) and knockback weapons when fighting near the void, and exposes a KillAuraAutoBlock setting needed for that decision-making.
Changes:
- Expose
onlyWhenInDangeras a readable property (isOnlyWhenInDanger) inKillAuraAutoBlock. - Add AutoWeapon toggles for 1.8 blocking priority and void knockback priority, and update weapon ranking comparator accordingly.
- Add a cached “near void” detection routine to drive knockback prioritization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
.../killaura/features/KillAuraAutoBlock.kt |
Exposes onlyWhenInDanger via a public getter for cross-module logic. |
.../combat/ModuleAutoWeapon.kt |
Adds new prioritization settings, comparator-based weapon ranking, and near-void detection with per-tick caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return bestSlot?.itemSlot as HotbarItemSlot? | ||
| } | ||
|
|
||
| private val CHECK_DISTANCES = doubleArrayOf(1.5, 3.0, 4.5, 6.0) |
Comment on lines
+268
to
+285
| for (dy in 0..16) { | ||
| val p = blockPos.below(dy) | ||
| if (p.y < level.minBuildHeight) { | ||
| break | ||
| } | ||
| val state = level.getBlockState(p) | ||
| if (!state.isAir && !state.getCollisionShape(level, p).isEmpty) { | ||
| hasBlockBelow = true | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if (!hasBlockBelow) { | ||
| voidBlocksCount++ | ||
| if (voidBlocksCount >= 2) { | ||
| return true | ||
| } | ||
| } |
Comment on lines
+273
to
+277
| val state = level.getBlockState(p) | ||
| if (!state.isAir && !state.getCollisionShape(level, p).isEmpty) { | ||
| hasBlockBelow = true | ||
| break | ||
| } |
a1cc737 to
f301e09
Compare
| return true | ||
| } | ||
|
|
||
| private fun isSupportingBlock(level: Level, pos: BlockPos, state: BlockState): Boolean { |
| val itemCategorization = ItemCategorization(Slots.Hotbar) | ||
| val requiresShield = autoShieldBreak && (enforceShield || target?.wouldBlockHit == true) | ||
| val requiresMace = autoMace && canMaceSmash | ||
| val requiresLegacySword = isOlderThanOrEqual1_8 && KillAuraAutoBlock.enabled && |
Contributor
There was a problem hiding this comment.
Sword block is not a "legacy" feature. Any item can be used to block on 1.21.5+. Your AI needs latest info. Directly check vanilla jar file.
| // An axe will stun the target if it is blocking with a shield | ||
| requiresShield -> weaponFacets.firstBestMatching { WeaponType.AXE.test(it.itemStack) } | ||
| // Legacy blocking favors swords when only blocking on danger | ||
| requiresLegacySword -> weaponFacets.firstBestMatching { WeaponType.SWORD.test(it.itemStack) } |
- Reuse the existing BlockPos.collisionShape extension for the void check instead of duplicating air/collision-shape detection. - Sword blocking is not a 1.8-only feature; gate the blocking-sword preference on isBlocksAttacksExisting so it also applies on 1.21.5+ where any item can block. Rename requiresLegacySword accordingly. - Drop the redundant isOnlyWhenInDanger wrapper by exposing onlyWhenInDanger directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…gles Both behaviors were previously unconditional. Now exposed as user-facing boolean settings (both enabled by default — no behavior change): - PreferBlockingSword: favors a sword when KillAura AutoBlock only blocks on danger and the player is currently in danger, so a blockable item is ready in hand. Applies on 1.8 and 1.21.5+ (isBlocksAttacksExisting). - PrioritizeVoidKnockback: prefers a weapon enchanted with Knockback when the target stands next to the void, to push them off the edge. Also adds tooltip descriptions for both new settings in all 12 bundled language files (+2 lines each, JSON valid). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The old heuristic cast a single ray behind the target and required 3 of 5 samples to be void. On a narrow strip (not a solid platform) a single ray rarely collected 3 void samples, so AutoWeapon kept the sword and the target survived a knockback that should have thrown them off. Now: - Fan out three rays (center + two angled) from the target along the knockback direction, accounting for knockback spread and thin ledges. - A ray fires if its nearest contiguous samples are all void, instead of an any-3-of-5 majority — so a clear drop right behind the target is enough, while a distant pit beyond solid ground still does not trigger. - Start sampling at 1.0 (behind the hitbox) out to 3.5 blocks, matching the knockback throw distance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces two new PvP priority mechanics to the
AutoWeaponmodule:1. 1.8 Block Priority
isOnlyWhenInDangervia a clean property accessor instead of coupling to configuration internals.2. Void Knockback Priority
floor(checkX).toInt()) instead of truncation (toInt()) to prevent coordinate shift on negative values.isNearVoidresults per tick per target entity, resulting in zero overhead on subsequent calls.