Repository navigation
feat: choose gun ammunition with crouch + right-click - #31
Conversation
Reloads took the first caliber in the gun's list that the player carried, so anyone holding a single iron shot could never load steel or powered shot. Crouch + right-click now steps to the next caliber the player carries and saves it on the gun; reloads use only that pick and say so when it runs out. Guns without a pick keep the old order. Caliber overrides also kept only the last caliber of the list, so Arclock rifles accepted mythrilshot_powered alone. The last part with an override now supplies all of its calibers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughGuns with multiple calibres can save a selected calibre and use it for the next reload. Players can cycle through supported calibres they carry by sneaking and right-clicking. Calibre resolution, gun rebuilding, action-bar messages, and tests are updated. ChangesAmmunition selection
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Player
participant GunManager
participant PlayerInventory
participant GunItem
Player->>GunManager: Sneaking right-click
GunManager->>PlayerInventory: Find carried supported calibres
PlayerInventory-->>GunManager: Matching ammunition stacks
GunManager->>GunItem: Save selected calibre
GunManager-->>Player: Show selected calibre and carried amount
Player->>GunManager: Reload
GunManager->>GunItem: Read selected calibre
GunManager->>PlayerInventory: Take ammunition for that calibre
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change adds saved calibre selection and selection-aware reloads; the available evidence establishes no concrete user-facing failure that should block merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Ammunition choice remains constrained to the held gun’s compatible ammunition and the player’s inventory. No expanded privileges or cross-player access were identified. A bounded recovery concern remains because new ammunition notifications execute before reload cleanup or task creation completes. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Comment |
Dev testing showed MMOCore's stat bar redrawing over the ammo message within a quarter second; reserve MythicLib's action bar at NORMAL priority for two seconds before sending it, and skip the message when a busier bar holds it. Trim the trailing space from ammo item names. One crouch-click on a block switched twice about one time in eight: its main- and off-hand events can land in neighbouring ticks. Ignore switch requests within two ticks of the last one; clients allow a new click only every four ticks. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Dev test: TFMCDev01, commit 3798603Ran a mineflayer bot as a Musketeer against the PR jar (
No GunsAndGadgets errors in Dev's The first Dev run found the two problems fixed in 3798603: the stat bar overwrote the message within about 0.25 s, and 1 in 8 block clicks switched twice. |
Why
Player suggestion
zmfy3-6wiir(D_ta, 7 ✅ / 0 ❌): "Change how Musketeer weapons pick which ammo in your inventory they use."A reload loads the first caliber in the gun's list that the player carries. On Main every list runs from weakest to strongest (e.g. rifled barrels:
ironshot→ironshot_powered→steelshot). Anyone carrying one iron shot could never load steel or powered shot without dropping the iron first.What changes for players
Next load: <shot> (N carried)with a lever click. The pick is saved on the gun, so each gun remembers its own.You have no <shot> left. Crouch and right-click to choose another.Loading <shot>on the action bar.Crouch and right-click to change shot.SWAP_HANDSto open skill casting.Arclock caliber fix
resolveCaliberskept only the last entry of acaliber-overridelist. On Main the Arclock overrides tobronzeshot, bronzeshot_powered, mythrilshot, mythrilshot_powered, so Arclock rifles only acceptedmythrilshot_powered. Now the last part that has an override supplies its whole list. Steamlock (ironshotonly) is unaffected.Calibers are stamped on the gun when it is built. Existing Arclocks keep the old single caliber until they are rebuilt: either
/gg refreshwhile holding one, or the automatic refresh after an Arclock part config change.Implementation notes
gunsandgadgets:ammo_selected(ammo key).copyRuntimeAmmoPdccarries it through rebuilds/refreshes.takeAmmois split intofindAmmo/countStacksso switching can count stacks the same way reloads do.handleGunUseas several interact events: one per hand on a block, or an entity click plus a right-click-air. These can land in neighbouring ticks; on Dev, one block click in eight switched twice with a same-tick guard. A switch request within 2 ticks of the last accepted one is now ignored. Clients allow a new click only every 4 ticks, so deliberate clicks are never swallowed.❤ … | ★ … | ⛨ …, every 5 ticks on Main) overwrote the message within ~0.25 s. Messages now reserve MythicLib's action bar atNORMALpriority for 40 ticks (2 s) before sending. If a higher-priority bar holds it, the message is skipped.Dev test (TFMCDev01, mineflayer bot as a Musketeer)
Covered: the lore hint, the first crouch-click picking steel over iron, the action bar text, the HUD pause, block clicks with duplicated off-hand packets, steel loading ahead of iron, crouch-click not firing a loaded gun, refusal once steel runs out (iron untouched), switching back to iron, the no-shot message, an Arclock rifle listing 4 calibers and loading bronze shot. Results are in the PR comments.
Tests
mvn clean verify: 171 tests pass, 100% line/branch/instruction coverage. New tests cover switching (skip + wrap, no fire/reload, repeat events of one click within 2 ticks ignored), no usable ammo, reload with a pick, refusal once the pick runs out (and recovery), stale pick fallback, the single-caliber case, override lists, the lore hint, preserving the pick on rebuild, and the action-bar reservation (and yielding to a busier bar).🤖 Generated with Claude Code