feat: draw-force based bow/crossbow attack indicator condition#1776
Open
Travja wants to merge 3 commits into
Open
feat: draw-force based bow/crossbow attack indicator condition#1776Travja wants to merge 3 commits into
Travja wants to merge 3 commits into
Conversation
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.
Open
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.
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.
Split out of #1677 (piece 3 of 8 — see that PR for the full breakdown).
What
AttackIndicatorConditionpreviously only checkedPlayer#getAttackCooldown(), which doesn't reflect bow/crossbow draw state. This adds aweaponsetting (auto,bow,crossbow) and computes a 0.0-1.0 draw-force value:ShootListener(registered inFabled#onEnable) snapshots the force fromEntityShootBowEventas short-lived caster metadata, since theLaunchtrigger 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