Skip to content

Add BlockStateMeta#clearBlockState#10160

Merged
Owen1212055 merged 2 commits into
PaperMC:masterfrom
Machine-Maker:feature/BlockStateMeta#clearBlockState
Jan 23, 2024
Merged

Add BlockStateMeta#clearBlockState#10160
Owen1212055 merged 2 commits into
PaperMC:masterfrom
Machine-Maker:feature/BlockStateMeta#clearBlockState

Conversation

@Machine-Maker
Copy link
Copy Markdown
Member

Resolves #10159


An alternative would be to make BlockStateMeta#setBlockState nullable. I don't know if we want to make that change, especially since the interface is already setup so the getter is nonnull and there is a has boolean method.

@Machine-Maker Machine-Maker requested a review from a team as a code owner January 11, 2024 20:43
@tal5
Copy link
Copy Markdown
Contributor

tal5 commented Jan 11, 2024

Not sure how big of a PR do you want to make this/maybe split it up into multiple, but as mentioned in the original issue there's a few other places with a similar problem:

  • ArmorStandMeta's values are all boolean (i.e. can't be cleared)
  • AxolotlBucketMeta's variant can't be cleared
  • CompassMeta's LodestoneTracked is a boolean and will always remain in NBT, etc.

Either way thank you very much for adding this!

@electronicboy
Copy link
Copy Markdown
Member

All those 3 boil down into the fundamental flaw of ItemMeta, which is why the property API is coming to be a thing

@Machine-Maker
Copy link
Copy Markdown
Member Author

Yeah, I agree with @electronicboy here. Those point to specific properties that can be reset. The property API is the way to handle that. Other similar clear methods pertain to whole groups of data, like PotionMeta#clearCustomEffects, FireworkMeta#clearEffects, and more, all exist and I think this falls into that category.

@Machine-Maker Machine-Maker force-pushed the feature/BlockStateMeta#clearBlockState branch from 0780648 to a77fac6 Compare January 13, 2024 00:57
@Owen1212055 Owen1212055 force-pushed the feature/BlockStateMeta#clearBlockState branch from a77fac6 to e4fb1a9 Compare January 23, 2024 20:24
@Owen1212055 Owen1212055 merged commit 24dc2bf into PaperMC:master Jan 23, 2024
@Machine-Maker Machine-Maker deleted the feature/BlockStateMeta#clearBlockState branch January 23, 2024 21:03
lynxplay pushed a commit to lynxplay/paper that referenced this pull request Feb 23, 2024
LeonTG pushed a commit to LeonTG/Paper that referenced this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

ItemMeta keeping default NBT values

4 participants