Skip to content

Fix ItemStackLike#maxStackQuantity#4177

Merged
aromaa merged 6 commits intoSpongePowered:api-12from
MrHell228:api-12-itemstack-fix
Mar 12, 2025
Merged

Fix ItemStackLike#maxStackQuantity#4177
aromaa merged 6 commits intoSpongePowered:api-12from
MrHell228:api-12-itemstack-fix

Conversation

@MrHell228
Copy link
Contributor

SpongeAPI | Sponge

Implements ItemStackLike#maxStackQuantity because it's no longer defaulted in API

Also adds ability to remove max durability & max stack size components

@MrHell228 MrHell228 force-pushed the api-12-itemstack-fix branch from 0d660b5 to f5f6345 Compare February 22, 2025 23:17
@aromaa
Copy link
Member

aromaa commented Mar 12, 2025

Should add the check for MAX_DURABILITY too? The API changes should be unnecessary with the new changes.

@MrHell228
Copy link
Contributor Author

MrHell228 commented Mar 12, 2025

Because get changed to return component value, it may return empty optional, meaning require in API will throw anyway.
Fixed Keys.MAX_DURABILITY (getter effectively unchanged but now follows general pattern for components)

@aromaa
Copy link
Member

aromaa commented Mar 12, 2025

Ah I didn't notice you changed that. Yeah, that should be left as ItemStack::getMaxStackSize.

@MrHell228
Copy link
Contributor Author

Haven't we agreed in discord that making it return component value is fine?

@aromaa
Copy link
Member

aromaa commented Mar 12, 2025

The whole point of removing the supports was that it would return the default value if the component was missing, right? :)

@MrHell228
Copy link
Contributor Author

MAX_STACK_SIZE component presence doesn't really correlate with MAX_DAMAGE component presence.
The only limitation is that if MAX_DAMAGE is present, MAX_STACK_SIZE must be either absent or equal to 1. And I guess it's impl detail that there is no behaviour difference between absence and equality to 1. But devs should be able to see if component is actually missing, or it's value set to 1

@aromaa
Copy link
Member

aromaa commented Mar 12, 2025

But devs should be able to see if component is actually missing

This is a whole separate issue that we have not yet decided up on how to deal with it. In that case we might want to delay this.

@MrHell228
Copy link
Contributor Author

MrHell228 commented Mar 12, 2025

Sad, but okay. Closed API PR, reverted changes related to API (including MAX_STACK_QUANTITY getter)

Copy link
Member

@aromaa aromaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aromaa aromaa merged commit 50b1c89 into SpongePowered:api-12 Mar 12, 2025
5 checks passed
@MrHell228 MrHell228 deleted the api-12-itemstack-fix branch March 12, 2025 18:30
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.

2 participants