Skip to content

fix(AttributeSwap): handle entity hits before spear checks and respect Hitboxes expansion - #6725

Merged
MineGame159 merged 2 commits into
MeteorDevelopment:masterfrom
Eccys:fix/attribute-swap-spear-hitbox
Oct 17, 2026
Merged

MineGame159 merged 2 commits into
MeteorDevelopment:masterfrom
Eccys:fix/attribute-swap-spear-hitbox

Conversation

@Eccys

@Eccys Eccys commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix
  • New feature

Description

Fixes several smart/spear swapping issues in AttributeSwap:

  1. In Minecraft.startAttack(), DoAttackEvent (onAttack) fires at HEAD before DataComponents.PIERCING_WEAPON is checked on the main-hand item. If the player holds a spear (or if onAttack swaps to a spear), startAttack() calls gameMode.piercingAttack() and returns early without calling gameMode.attack(), preventing AttackEntityEvent (onAttackEntity) from firing. Handling EntityHitResult directly in onAttack via performSwap ensures that attacking an entity in melee/hitbox range properly swaps to a Mace, Axe, or Sword even when holding a spear, and prevents entity hits from falling through to the missed-attack spearHitbox / enchantLunge logic.
  2. Includes Hitboxes.getEntityValue(entity) when inflating entity bounding boxes in getTargetEntity() so extended hitbox attacks do not miss the target check and erroneously swap to a Lunge spear.
  3. Prevents spearHitbox from falling through to enchantLunge when a target entity is present and excludeLungeFromHitbox is enabled, and checks the currently selected hotbar slot first in getSmartSpearSlot.
  4. Adds the missing spear toggle to Weapon Options (only-on-weapon).

Related issues

Fixes #6226
Fixes #6560

How Has This Been Tested?

Verified compilation against Minecraft 26.2 (./gradlew compileJava) and tested smart/simple swapping behavior with spears, maces, axes, swords, and the Hitboxes module.

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

@MineGame159
MineGame159 merged commit aba7735 into MeteorDevelopment:master Oct 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attribute Swapping works but doesnt [Bug] spear issues

2 participants