Repository navigation
perf: trace the Hand Pick crosshair once per tick and only near a site - #37
Conversation
The Hand Pick tick ran for every online player every tick. It matched the held tool up to three times, traced the crosshair up to three times and looked the target up in the site list each time, even for players holding no excavation tool or standing nowhere near an excavation. - A player without a whitelisted tool now only has the mining lock cleared; the crosshair is not traced (the result was never used). - The crosshair is traced only when an established excavation's ruin chunk is within trace reach. A prism never leaves its ruin chunk, so outside that range the lookup could never find a site. - One trace and one site lookup per tick now serve both the mining lock and the HUD. A cycling player needs no trace at all. - Matching a stack against the whitelist asks ItemsAdder and MMOItems for its ids once per match instead of once per configured entry. The lock, HUD text and cue timing are the same on the same tick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Cache item lookups and restore allowed tools src/main/java/net/tfminecraft/archaeo/item/ItemMatcher.java, src/main/java/net/tfminecraft/archaeo/excavation/DigTools.java, src/test/java/net/tfminecraft/archaeo/item/DigToolsTest.java, src/test/java/net/tfminecraft/archaeo/item/ItemMatcherPackIT.java |
ItemMatcher adds a per-stack Probe that caches ItemsAdder and MMOItems lookups. DigTools reuses one probe across configured references and separates allowed-tool restoration from whitelist checking. Tests cover probe reuse and the updated matcher call. |
Query established sites by chunk bounds src/main/java/net/tfminecraft/archaeo/site/SiteRepository.java, src/test/java/net/tfminecraft/archaeo/site/SiteRepositoryTest.java |
SiteRepository adds an inclusive chunk-range query for established sites in a named world. Tests cover range boundaries, world names, and lifecycle status. |
Reuse nearby-site targeting for mining lock and HUD src/main/java/net/tfminecraft/archaeo/excavation/HandPickService.java, src/test/java/net/tfminecraft/archaeo/excavation/HandPickServiceTest.java |
HandPickService checks for a nearby established site before tracing. It reuses the target for mining-lock and HUD updates, and uses a shared reach constant. Tests cover tool changes, skipped traces, and trace reuse within a tick. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Sequence Diagram(s)
sequenceDiagram
actor Player
participant HandPickService
participant DigTools
participant SiteRepository
Player->>HandPickService: tick
HandPickService->>DigTools: restoreAllowedTool
HandPickService->>SiteRepository: hasEstablishedIn(world, chunk bounds)
SiteRepository-->>HandPickService: established-site result
HandPickService->>HandPickService: trace to REACH when a site is nearby
HandPickService->>Player: update mining lock and HUD
Suggested reviewers: nowkoo, ryanbarlow97
Merge Risk: 
Minimal · up to f69ca
-
No concrete merge-blocking issue was found. A real-dig check remains useful because the locked mining and HUD path was not exercised on the Dev server.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
@coderabbitai review |
✅ Action performed
|
Why
Main profiles, 22 hourly spark dumps 10-29 07:00 → 10-30 05:00 (peak ~30 players, ~23 ms/tick total).
HandPickService.tickcost 0.25 ms/tick. Every tick, for every player:syncHeldTool, includinggetTargetBlockExactray-traces andisExcavationFill;DigTools.isAllowed → ItemMatcher.matches(ItemsAdder/MMOItems id lookups, with item NBT copies).Change
SiteRepository.hasEstablishedIn). A trace can't return a prism cell farther away.ItemMatcherasks ItemsAdder/MMOItems for a stack's id once per check instead of once per configured entry.Testing
SiteEstatesTestfailures asmain. Pack-API integration tests 10/10.arprobe.json an established site: hold a Hand Pick and look at fill, swap tools, look away, walk off. The new jar and the previous jar gave identical results, with no errors.🤖 Generated with Claude Code