Skip to content

Limit item stack size#6383

Closed
valaphee wants to merge 0 commit into
GeyserMC:masterfrom
valaphee:max-item-stack-size
Closed

Limit item stack size#6383
valaphee wants to merge 0 commit into
GeyserMC:masterfrom
valaphee:max-item-stack-size

Conversation

@valaphee
Copy link
Copy Markdown
Member

When an item stack which is larger than 64 is sent, the client just disconnects without any information.

Copilot AI review requested due to automatic review settings May 10, 2026 12:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Bedrock client disconnects caused by receiving item stacks with counts greater than 64 by clamping the translated Bedrock ItemData count.

Changes:

  • Add a shared max stack size constant and clamp counts in the base Item#translateToBedrock implementation.
  • Clamp counts in PotionItem and TippedArrowItem override paths that build ItemData directly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
core/src/main/java/org/geysermc/geyser/item/type/Item.java Introduces a shared max stack size constant and clamps outgoing Bedrock item counts in the base translation path.
core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java Clamps counts in potion translation branches that bypass the base Item builder path.
core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java Clamps counts in tipped-arrow translation branch that bypasses the base Item builder path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 155 to 165
public ItemData.Builder translateToBedrock(GeyserSession session, int count, DataComponents components, ItemMapping mapping, ItemMappings mappings) {
if (this == Items.AIR || count <= 0) {
// Return, essentially, air
return ItemData.builder();
}

return ItemData.builder()
.definition(mapping.getBedrockDefinition())
.damage(mapping.getBedrockData())
.count(count);
.count(Math.min(count, MAX_STACK_SIZE));
}
import java.util.Map;

public class Item {
public static final int MAX_STACK_SIZE = 64;
.definition(mapping.getBedrockDefinition())
.damage(potion.tippedArrowId())
.count(count);
.count(Math.min(count, MAX_STACK_SIZE));
@valaphee valaphee closed this May 10, 2026
@valaphee valaphee force-pushed the max-item-stack-size branch from 970b265 to d2ef08c Compare May 10, 2026 13:22
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