Fixed the armor hud crashing when durability text is enabled - #6662
Open
c8dhjp4tyv-bit wants to merge 1 commit into
Open
c8dhjp4tyv-bit wants to merge 1 commit into
c8dhjp4tyv-bit wants to merge 1 commit into
Conversation
c8dhjp4tyv-bit
force-pushed
the
fix/armor-hud-durability-text-crash
branch
from
September 13, 2026 19:22
6c3f8c2 to
6bd1ffa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
Setting the armor hud's Durability to
TotalorPercentagecrashes the game as soon as the element is drawn:ArmorHuddraws its items from arenderer.post(...)task, and the durability text inside that task was drawn with the globalTextRenderer.get()without ever beginning it. Post tasks are the last thingHudRenderer.end()does, after the text batch for the frame has already been flushed:so by the time the task runs, neither text renderer is building and
render()throws. This affects both fonts —CustomTextRendererthrows the same (copy-pasted) message, which is why the report's crash log points atCustomTextRenderer.The fix is the pattern
CombatHudalready uses for the text it draws inside its own post task: begin the renderer around the text and end it afterwards. It is begun once for all four slots rather than per slot, and only when durability text is actually enabled, so there is one extra text batch per frame at most. The renderer is resolved into a local so that the begin, the measurements, the render and the end all go through the same instance.Since the text is now measured and drawn by the same renderer, the layout calls were moved over to it as well (
TextRenderer.get().getWidth/getHeightinstead ofrenderer.textWidth/textHeight).renderer.textWidth()measures withHudRenderer's own font atlas, which is not the fontTextRenderer.get()draws with, so the old code could not centre the number reliably even when it happened not to crash. The measurements are now also shadow-aware, matching thedurability-shadowsetting used when rendering.The
itemStack.isDamageableItem() && durability.get() != ...condition was hoisted into thedurabilityTextlocal; it is loop-invariant apart from the per-stack check.Related issues
Closes #6576
How Has This Been Tested?
./gradlew compileJavapasses.The crash is deterministic and reproduces from the report's steps on both font settings: add the armor hud, set Durability to
Percentage(orTotal) and leave the hud editor. Before the change the client crashes on the first frame the element is drawn; after it the durability numbers render centred under each armor piece, with Custom Font both on and off, inHorizontalandVerticalorientation.I also checked the other hud elements that draw from a post task —
ItemHud,InventoryHud,HoleHud,MapHud,PlayerModelHuddraw no text there, andCombatHudalready begins/ends its renderers itself — soArmorHudwas the only affected call site.Checklist: