Skip to content

add method on ItemStack to edit pdc#12022

Merged
Machine-Maker merged 4 commits into
PaperMC:mainfrom
Machine-Maker:feature/ItemStack-editPdc
Feb 16, 2025
Merged

add method on ItemStack to edit pdc#12022
Machine-Maker merged 4 commits into
PaperMC:mainfrom
Machine-Maker:feature/ItemStack-editPdc

Conversation

@Machine-Maker
Copy link
Copy Markdown
Member

Adds ItemStack#editPersistentDataContainer(Consumer<PersistentDataContainer>) which complements ItemStack#getPersistentDataContainer which returns a read-only view of the pdc on that stack.

The reason the consumer model is needed here is to allow multiple changes to the PDC without having to do lots and lots of copies. If we just had direct set methods, it would have to make a full copy on each set.

@Machine-Maker Machine-Maker requested a review from a team as a code owner January 27, 2025 04:35
@Warriorrrr Warriorrrr added type: feature Request for a new Feature. scope: api labels Jan 27, 2025
@lynxplay lynxplay force-pushed the feature/ItemStack-editPdc branch from 7244351 to 89ace40 Compare February 8, 2025 21:38
Comment thread paper-api/src/main/java/org/bukkit/inventory/ItemStack.java
@lynxplay
Copy link
Copy Markdown
Contributor

We should open a docs PR to include the changes on the PDC page (thanks Lulu)

@Machine-Maker Machine-Maker merged commit 608f004 into PaperMC:main Feb 16, 2025
@Machine-Maker Machine-Maker deleted the feature/ItemStack-editPdc branch February 16, 2025 19:01
Y2Kwastaken pushed a commit to Y2Kwastaken/Paper that referenced this pull request Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: feature Request for a new Feature.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

5 participants