Skip to content

feat: draw-force based bow/crossbow attack indicator condition#1776

Open
Travja wants to merge 3 commits into
devfrom
split/1677-attack-indicator-bow-crossbow
Open

feat: draw-force based bow/crossbow attack indicator condition#1776
Travja wants to merge 3 commits into
devfrom
split/1677-attack-indicator-bow-crossbow

Conversation

@Travja

@Travja Travja commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Split out of #1677 (piece 3 of 8 — see that PR for the full breakdown).

What

AttackIndicatorCondition previously only checked Player#getAttackCooldown(), which doesn't reflect bow/crossbow draw state. This adds a weapon setting (auto, bow, crossbow) and computes a 0.0-1.0 draw-force value:

  • Bow: fraction of full draw based on item-in-use ticks.
  • Crossbow: 1.0 once charged (accounting for Quick Charge), otherwise partial draw progress.
  • A new ShootListener (registered in Fabled#onEnable) snapshots the force from EntityShootBowEvent as short-lived caster metadata, since the Launch trigger fires after the bow/crossbow state has already reset.

Paper-only APIs (getActiveItem, CrossbowMeta#isCharged) are accessed via reflection with a Spigot-compatible fallback, since the project compiles against the Spigot API but runs on Paper.

Why split out separately

Self-contained condition + one listener registration; unrelated to any of the other pieces.

Note for reviewers

The reflection fallback is a bit unusual for this codebase — worth confirming that's the intended way to bridge the Paper/Spigot API gap here versus, e.g., an existing compat layer.

Testing

Could not build locally (private Maven repo unreachable in this sandbox). Needs manual testing on a Paper server: bow/crossbow draw indicator values while charging, at full draw, and immediately after firing.


Generated by Claude Code

Split out of #1677 (piece 3 of 8).

AttackIndicatorCondition previously only checked Player#getAttackCooldown(),
which doesn't reflect bow/crossbow draw state. This adds a weapon setting
("auto", "bow", "crossbow") and computes a 0.0-1.0 draw-force value:

- Bow: fraction of full draw based on item-in-use ticks.
- Crossbow: 1.0 once charged (accounting for Quick Charge), otherwise
  partial draw progress.
- A new ShootListener (registered in Fabled#onEnable) snapshots the
  force from EntityShootBowEvent as short-lived caster metadata, since
  the Launch trigger fires after the bow/crossbow state has already
  reset.

Paper-only APIs (getActiveItem, CrossbowMeta#isCharged) are accessed via
reflection with a Spigot-compatible fallback, since the project compiles
against the Spigot API but runs on Paper.

## Testing
Could not build locally (private Maven repo unreachable in this
sandbox). Needs manual testing on a Paper server: bow/crossbow draw
indicator values while charging, at full draw, and immediately after
firing.
@Travja Travja mentioned this pull request Jul 21, 2026
claude added 2 commits July 21, 2026 18:42
Covers the crossbow weapon mode (charged -> full value, within a high
min/max range) and that a non-player caster always fails the condition.

Deliberately not covered: the ShootListener metadata-capture path (would
need to construct a real EntityShootBowEvent, which nothing else in this
codebase does, so its constructor isn't modeled anywhere to copy) and the
Paper-only reflection fallbacks for getActiveItem/CrossbowMeta#isCharged
- those need manual/in-game verification since MockBukkit's support for
them isn't established here.
java.lang.reflect.Method and AttackIndicatorCondition were referenced
by fully-qualified name inline instead of via a normal import.
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.

2 participants