Skip to content

Prevent creating itemstack with more than 99 amount#12214

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

Prevent creating itemstack with more than 99 amount#12214
ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 2, 2025

Instead of blowing up later (minecraft limits item stack amount between 1 and 99 inclusive)

Fixes #12213

@ghost ghost self-requested a review as a code owner March 2, 2025 10:39
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Mar 2, 2025
@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 2, 2025

I assume there used to be an upper bound of 64 but when 1.20.5 came out it was removed because someone wasn't sure what the new max item amount limit was

public static @NotNull ItemStack of(final @NotNull Material type, final int amount) {
Preconditions.checkArgument(type.asItemType() != null, type + " isn't an item");
Preconditions.checkArgument(amount > 0, "amount must be greater than 0");
Preconditions.checkArgument(amount > 99, "amount must be no greater than 99");
Copy link
Copy Markdown
Member

@Doc94 Doc94 Mar 2, 2025

Choose a reason for hiding this comment

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

Currently you only allow over 99 in amount

Suggested change
Preconditions.checkArgument(amount > 99, "amount must be no greater than 99");
Preconditions.checkArgument(amount <= 99, "amount must be no greater than 99");

@Doc94
Copy link
Copy Markdown
Member

Doc94 commented Mar 2, 2025

Maybe can be good add the range annotation to the amount. Also docs missing mention the limit

@lynxplay
Copy link
Copy Markdown
Contributor

lynxplay commented Mar 2, 2025

See #12213 (comment)

@lynxplay lynxplay closed this Mar 2, 2025
@github-project-automation github-project-automation Bot moved this from Awaiting review to Closed in Paper PR Queue Mar 2, 2025
@electronicboy
Copy link
Copy Markdown
Member

A big issue is that many plugins end up doing stuff like using an oversized stack amount in order to let the server deal with splitting it out, we couldn't change such behaviour without breaking a whole host of plugins

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

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Failed to encode Minecraft Component on displayName()

3 participants