mojira.dev
MC-307985

Bundle tooltip component calculating items to display incorrectly

Still present in 26.1.2 - root cause analysis is bug in math in net.minecraft.world.item.component.BundleContents#getNumberOfItemsToShow()

current code:

public int getNumberOfItemsToShow() {
    int numberOfItemStacks = this.size();
    int availableItemsToShow = numberOfItemStacks > 12 ? 11 : 12;
    int itemsOnNonFullRow = numberOfItemStacks % 4;
    int emptySpaceOnNonFullRow = itemsOnNonFullRow == 0 ? 0 : 4 - itemsOnNonFullRow;
    return Math.min(numberOfItemStacks, availableItemsToShow - emptySpaceOnNonFullRow);
}

correct code:

public int getNumberOfItemsToShow() {
    int numberOfItemStacks = this.size();
    int availableItemsToShow = numberOfItemStacks > 12 ? 11 : 12;
    int itemsOnNonFullRow = availableItemsToShow % 4; // <-- here it should take how many items should be in last row
    int emptySpaceOnNonFullRow = itemsOnNonFullRow == 0 ? 0 : 4 - itemsOnNonFullRow;
    return Math.min(numberOfItemStacks, availableItemsToShow - emptySpaceOnNonFullRow);
}

the whole logic could be simplified though to:

public int getNumberOfItemsToShow() {
    return Math.min(this.size(), 11);
}

Linked issues

Comments 3

Duplicates MC-275217, which is already resolved as WAI.

The behavior is also mentioned in 1.21.2 chagelog:

If a Bundle has less than 12 item types inside, the tooltip will show all of them
Otherwise, the tooltip will show the top three rows of items (at least 8 item types) and the others will be hidden below

Also, your oversimplification will make the tooltip show unneccessary “+1” when the bundle contains exactly 12 stacks of items.

Hi!
Thank you for your report! 

We've already resolved this issue at MC-275217 , so I will close and link this ticket as a Duplicate.

Quick Links: 
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki

If this is WAI then I don’t know who decided that we are not reading from top-left to bottom-right - first slot is empty background, overall this thing just looks ugly, is not user-friendly in terms etc. And completely unnecessary niche bullshit imho.

Nightenom

(Unassigned)

Unconfirmed

26.1.2

Retrieved