Skip to content

feat(plugin-api): add item stack persistent data container v1#1991

Draft
CompileRider wants to merge 3 commits intoPumpkin-MC:masterfrom
CompileRider:feat/pdc-itemstack-v1
Draft

feat(plugin-api): add item stack persistent data container v1#1991
CompileRider wants to merge 3 commits intoPumpkin-MC:masterfrom
CompileRider:feat/pdc-itemstack-v1

Conversation

@CompileRider
Copy link
Copy Markdown
Contributor

@CompileRider CompileRider commented Apr 8, 2026

Problem

Pumpkin plugins currently have no persistent data container support. Issue #635 asks for broad owner coverage, but the current plugin/WASM surface only cleanly exposes ItemStack as a first real public owner.

This PR ships the first usable slice instead of a foundation-only refactor:

  • additive v0.2.0
  • Foundation + ItemStack only
  • no Entity owner yet
  • no typed PDC helpers yet

What changed

  • pumpkin-data/src/item_stack/mod.rs: adds ItemStack-owned plugin PDC storage and NBT round-trip persistence under pumpkin:plugin_data
  • pumpkin-plugin-wit/v0.2.0/*: adds the additive v0.2.0 guest surface plus the new item-stack resource and PDC methods
  • pumpkin-plugin-api/{Cargo.toml,src/lib.rs}: moves the guest crate onto the new versioned surface
  • pumpkin/src/plugin/loader/wasm/wasm_host/*: adds v0.2.0 host/version dispatch and the ItemStack resource backing
  • Cargo.lock: refreshes the workspace lockfile used by this branch

Testing

  • cargo fmt --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test -p pumpkin-data pdc_ -- --nocapture
  • cargo test -p pumpkin-data item_stack_serialization_round_trips_plugin_data -- --nocapture
  • cargo test -p pumpkin item_stack_resource_mutates_real_owner --no-run
  • Direct execution of the compiled item_stack_resource_mutates_real_owner test binary
  • cargo audit, lol

Scope

  • keeps v0.1.0 working
  • adds additive v0.2.0
  • keeps the first PR limited to ItemStack
  • leaves Entity and the broader owner matrix for later work

Part of #635

this is the first shippable slice of Pumpkin-MC#635

it adds a reusable pdc foundation
it exposes ItemStack as the first public owner through v0.2.0
future owners such as Entity remain follow-up work
@CompileRider CompileRider marked this pull request as draft April 9, 2026 00:04
@CompileRider
Copy link
Copy Markdown
Contributor Author

Switching this back to draft for now. After revisiting the implementation, I think there’s a better way to structure parts of this PR, so I want to clean that up before putting it up for full review.

@CompileRider
Copy link
Copy Markdown
Contributor Author

CompileRider commented Apr 9, 2026

This is a disaster, time for coffee

The public ItemStack PDC goal does not change in this pass.

Reuse the unchanged v0.1.0 host bindings from the v0.2.0 world instead of keeping duplicated v0_2_0 host modules for commands, events, context, gui, scoreboard, text, world, and other unchanged interfaces.

This keeps v0.1.0 compatibility intact, leaves ItemStack as the only real owner in v0.2.0, and removes the oversized wrapper churn without adding typed helpers or new owners.
@RoosterBooster007 RoosterBooster007 added the api Anything that deals with Pumpkin's plugin API label Apr 9, 2026
@illyrius666
Copy link
Copy Markdown
Contributor

~6k lines are going to be a hell to review in one pr, wouldnt it be better to split this up into multiple pr's?

@CompileRider
Copy link
Copy Markdown
Contributor Author

That was a fair concern for the earlier ~6k-line version, and I agreed with it there.

After the reduction, I don’t think splitting it further would help much. The remaining size is mostly the additive v0.2.0 access path needed to expose ItemStack as a real first owner, and splitting now would mostly turn this into an infrastructure-first PR plus a dependent feature PR.

So I’m keeping it as one draft PR and focusing on making the remaining shape easier to review.

This keeps the ItemStack PDC feature goal unchanged.

It extracts the duplicated player host implementation into a shared internal layer, leaves v0.1.0 and v0.2.0 as thin wrappers, and keeps only the ItemStack resource access delta in v0.2.0.

No new owners or typed helpers are added, and the public PDC slice remains Foundation + ItemStack only.
@CompileRider
Copy link
Copy Markdown
Contributor Author

I did one more structural reduction pass before taking this out of draft.

The main remaining weakness in the reduced branch was that v0_2_0/player.rs was still carrying a large manual copy of the player host implementation, even though the actual v0.2.0 delta for this lane is very small.

That has now been refactored so the shared player host logic lives in wit/player_shared.rs, while the versioned wrappers stay thin:

  • v0_1_0/player.rs is now just the v0.1.0 wrapper
  • v0_2_0/player.rs is now just the v0.2.0 wrapper plus the two ItemStack resource accessors required for this PR

So although the total diff vs origin/master changed numerically, the structure is much better now:

  • the duplicated player host implementation is gone
  • the versioned player.rs files are no longer broad manual copies
  • the remaining v0.2.0 code now reads like a real delta for the ItemStack PDC slice instead of a second full player host implementation

At this point, the remaining heaviness is mostly the shared implementation itself and the versioned API surface, not duplicated wrapper churn.

@CompileRider CompileRider changed the title feat(plugin-api): add item stack persistent data container v1 feat(plugin-api): add item stack persistent data container Apr 9, 2026
@CompileRider CompileRider changed the title feat(plugin-api): add item stack persistent data container feat(plugin-api): add item stack persistent data container v Apr 9, 2026
@CompileRider CompileRider changed the title feat(plugin-api): add item stack persistent data container v feat(plugin-api): add item stack persistent data container v1 Apr 9, 2026
@Snowiiii
Copy link
Copy Markdown
Member

There will be no v0.2.0 since there isn't even an official v0.1 release

@CompileRider
Copy link
Copy Markdown
Contributor Author

There will be no v0.2.0 since there isn't even an official v0.1 release

I understand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Anything that deals with Pumpkin's plugin API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants