Skip to content

Track storage inventories across Folia regions#293

Draft
Alexteens24 wants to merge 1 commit into
OpenVdra:mainfrom
Alexteens24:agent/track-storage-inventories
Draft

Track storage inventories across Folia regions#293
Alexteens24 wants to merge 1 commit into
OpenVdra:mainfrom
Alexteens24:agent/track-storage-inventories

Conversation

@Alexteens24

Copy link
Copy Markdown
Contributor

What changed

  • Track SmartSpawner storage inventories by object identity in a synchronized registry.
  • Resolve storage sessions from that registry in click, drag, close, transfer, and display paths instead of probing arbitrary inventories with Inventory#getHolder().
  • Remove registry entries when the corresponding inventory closes.
  • Schedule player GUI updates with the entity scheduler so they follow players across Folia region changes.
  • Only enqueue main-menu refreshes for viewers actually tracked as main-menu viewers.

Root cause

The listener used getHolder(false) to determine whether every incoming inventory belonged to SmartSpawner. On modern versions, a player can retain a block inventory across a teleport. The player thread can therefore own region B while the block-backed inventory still belongs to region A, and merely resolving its holder performs a forbidden cross-region block-state read.

Moving holder resolution into InventoryCloseEvent is not sufficient because the close itself may happen after the region change. Thread checks also require a safely known location first. Tracking only the virtual inventories SmartSpawner creates avoids touching unrelated block inventories entirely. Entity scheduling remains appropriate for operations that target the player because it follows the entity across regions.

Impact

SmartSpawner no longer probes arbitrary chest or block inventories from its storage listeners, and storage viewer updates remain valid when players change Folia regions. This follows up on #292.

Validation

  • ./gradlew :core:compileJava
  • git diff --check

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.

1 participant