Repository navigation
perf: read the live holder in the grave hopper check - #141
Conversation
Hopper moves run isGraveInventory on both inventories for every transfer. Inventory#getHolder() builds a BlockState snapshot that copies the whole chest just so we can find its block; in the 10-22 Main spark profile that copy was ~1.9% of all server-thread time. getHolder(false) returns the live block entity instead, with the same block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kkit MockBukkit 4.95 does not implement Inventory#getHolder(boolean); it threw UnimplementedOperationException, which the extension reports as a skip, so graveBlocksResistBreaksExplosionsPistonsAndHoppers silently stopped running. Spy the grave chest inventory and return its holder instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Live holder lookup and validation src/main/java/net/tfminecraft/rpcharacters/grave/GraveInteractListener.java, src/test/java/net/tfminecraft/rpcharacters/grave/GraveEventsTest.java |
inventoryBlock uses getHolder(false). The test checks that hopper movement into a grave chest is cancelled when the destination inventory has a live chest holder, without calling getHolder() on that inventory. |
Priority:
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Refactor
Possibly related PRs
- TF-Minecraft/RPCharacters#136: Changes the grave tag lookup during hopper checks. This PR changes the inventory holder lookup in the same grave hopper-check path.
Suggested reviewers: ryanbarlow97
Merge Risk: 
Minimal · up to 5f4a2
-
The live-holder lookup preserves grave detection for the stated inventory types while avoiding the snapshot lookup.
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
|
|
Dev test (10-28 09:4x UTC): this class was swapped into Dev's current RPC jar (javap showed |
Why
Players report TPS dips on Main. In the 10-22 spark profile (hPFtqh9M5c), the grave check on hopper moves cost 7.1 % of all server-thread time. #136 fixed 5.2 % of that (
GraveManager.getAtcopied the chest viagetState()). The other 1.9 % is still there:GraveInteractListener.inventoryBlockcallsInventory#getHolder(), which on Paper also builds aBlockStatesnapshot of the whole chest, just so we can read its block. It runs on both inventories of everyInventoryMoveItemEvent.Change
inventoryBlockasks for the live holder withgetHolder(false). The block it returns is the same, so the grave check gives the same answer:DoubleChestholder, so they fall through togetLocation()as before;GraveEventsTest: MockBukkit 4.95 does not implementgetHolder(boolean)and threwUnimplementedOperationException, which the extension reports as a skip. The grave chest inventory is now a spy that returns its holder, and a new assertion checks that hopper moves never callgetHolder().Testing
GraveEventsTest: 32 run, 0 failures, 0 skipped. On Windows the full suite has its usual file-system failures (atomic moves, POSIX permissions); none of them touch this code, and Linux CI is the reference.🤖 Generated with Claude Code