-
Notifications
You must be signed in to change notification settings - Fork 0
Item Count GUI Rendering
In vanilla Minecraft, item count numbers rendered on inventory slots are formatted for small numbers (1000000), the rendered text overflows the 16x16 pixel slot bounds and overlaps neighboring inventory slots.
GuiGraphicsExtractorMixin intercepts client slot rendering and delegates to ItemCountRenderer.renderItemCount:
public class ItemCountRenderer {
public static void renderItemCount(GuiGraphicsExtractor graphics, Font font, ItemStack itemStack, int x, int y, String countText) {
if (itemStack.getCount() != 1 || countText != null) {
String amount = countText == null ? String.valueOf(itemStack.getCount()) : countText;
int textWidth = font.width(amount);
float maxAllowedWidth = 16.0f;
if (textWidth > maxAllowedWidth) {
float scale = maxAllowedWidth / textWidth;
Matrix3x2fStack pose = graphics.pose();
pose.pushMatrix();
float targetRight = x + 17;
float targetBottom = y + 9;
pose.translate(targetRight, targetBottom);
pose.scale(scale, scale);
graphics.text(font, amount, -textWidth, 0, -1, true);
pose.popMatrix();
} else {
graphics.text(font, amount, x + 17 - textWidth, y + 9, -1, true);
}
}
}
}Let
| Item Count | String Length | Standard Width ( |
Applied Scale ( |
Rendering Behavior |
|---|---|---|---|---|
64 |
2 chars | Standard Vanilla font size | ||
1000 |
4 chars | Dynamically scaled to fit slot | ||
1000000 |
7 chars | Compact high-precision fit |
📌 Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.
Copyright © 2026 Dasik (Rifaditya). Licensed under the GNU General Public License v3.0 (GPLv3).
🏠 Home
- Dynamic GameRules
- Category Stack Limits
- Container Drop Optim.
- Large Chest Overflow
- ModMenu & YACL Config
- Item Count Rendering
- Item Clumps Synergies
- Troubleshooting & FAQ
- Developer Setup
- Architecture Layout
- Mixin Reference
- Addon Override API
- Network Sync Protocol
- Give Command Handling
- Behavior Profiles
- Consumer Mods Guide
- Performance Impact
- Advancements Matrix
- Author: Dasik (Rifaditya)
- License: GPL-3.0-or-later